Python keyboard keys list

class Keyboard

The Keyboard class is used to collect keyboard responses. You generally create a Keyboard object with the Keyboard() factory function, as described in the section Creating a Keyboard.

# Wait for a 'z' or 'x' key with a timeout of 3000 ms my_keyboard = Keyboard(keylist=['z', 'x'], timeout=3000) start_time = clock.time() key, end_time = my_keyboard.get_key() var.response = key var.response_time = end_time - start_time 

Things to know

Creating a Keyboard

You generally create a Keyboard with the Keyboard() factory function:

Optionally, you can pass Response keywords to Keyboard() to set the default behavior:

my_keyboard = Keyboard(timeout=2000) 

Key names

  • Key names may differ between backends.
  • Keys can be identified either by character or name, and are case-insentive. For example:
  • The key ‘a’ is represented by ‘a’ and ‘A’
  • The up arrow is represented by ‘up’ and ‘UP’
  • The ‘/’ key is represented by ‘/’, ‘slash’, and ‘SLASH’
  • The spacebar is represented by ‘space’ and ‘SPACE’
  • To find out the name of key, you can:
  • Click on the ‘list available keys’ button of the keyboard_response item.
  • Collect a key press with a keyboard_response item, and display the key name through a feedback item with the text ‘You pressed [response]’ in it.

Response keywords

Functions that accept **resp_args take the following keyword arguments:

  • timeout specifies a timeout value in milliseconds, or is set to None to disable the timeout.
  • keylist specifies a list of keys that are accepted, or is set to None accept all keys.
# Get a left or right arrow press with a timeout of 3000 ms my_keyboard = Keyboard() key, time = my_keyboard.get_key(keylist=[u'left', u'right'], timeout=3000) 

Response keywords only affect the current operation (except when passed to Python keyboard keys list[init]). To change the behavior for all subsequent operations, set the response properties directly:

# Get two key A or B presses with a 5000 ms timeout my_keyboard = Keyboard() my_keyboard.keylist = [u'a', u'b'] my_keyboard.timeout = 5000 key1, time1 = my_keyboard.get_key() key2, time2 = my_keyboard.get_key() 

Or pass the response options to Python keyboard keys list[init]:

# Get two key A or B presses with a 5000 ms timeout my_keyboard = Keyboard(keylist=[u'a', u'b'], timeout=5000) key1, time1 = my_keyboard.get_key() key2, time2 = my_keyboard.get_key() 

function Keyboard.flush()

Clears all pending keyboard input, not limited to the keyboard.

Читайте также:  Img html adding images

True if a key had been pressed (i.e., if there was something to flush) and False otherwise.

function Keyboard.get_key(**resp_args)

Collects a single key press.

my_keyboard = Keyboard() response, timestamp = my_keyboard.get_key(timeout=5000) if response is None: print(u'A timeout occurred!') 

Keyword dict:

  • **resp_args : Optional response keywords ( timeout and keylist ) that will be used for this call to Keyboard.get_key()`. This does not affect subsequent operations.

A (key, timestamp) tuple. key is None if a timeout occurs.

function Keyboard.get_key_release(**resp_args)

Collects a single key release.

Important: This function currently assumes a QWERTY keyboard layout (unlike Keyboard.get_key() ). This means that the returned key may be incorrect on non-QWERTY keyboard layouts. In addition, this function is not implemented for the psycho backend.

my_keyboard = Keyboard() response, timestamp = my_keyboard.get_key_release(timeout=5000) if response is None: print(u'A timeout occurred!') 

Keyword dict:

  • **resp_args : Optional response keywords ( timeout and keylist ) that will be used for this call to Keyboard.get_key_release() . This does not affect subsequent operations.

A (key, timestamp) tuple. key is None if a timeout occurs.

function Keyboard.get_mods()

Returns a list of keyboard moderators (e.g., shift, alt, etc.) that are currently pressed.

my_keyboard = Keyboard() moderators = my_keyboard.get_mods() if u'shift' in moderators: print(u'The shift-key is down!') 

A list of keyboard moderators. An empty list is returned if no moderators are pressed.

function Keyboard.show_virtual_keyboard(visible=True)

Shows or hides a virtual keyboard if this is supported by the back-end. This function is only necessary if you want the virtual keyboard to remain visible while collecting multicharacter responses. Otherwise, Keyboard.get_key() will implicitly show and hide the keyboard for a single-character response.

This function does nothing for back-ends that do not support virtual keyboards.

my_keyboard = Keyboard() my_keyboard.show_virtual_keyboard(True) response1, timestamp2 = my_keyboard.get_key() response2, timestamp2 = my_keyboard.get_key() my_keyboard.show_virtual_keyboard(False) 
  • visible — True if the keyboard should be shown, False otherwise.
    • Type: bool
    • Default: True

    Supported by Supported by

    Источник

    Tkinter 8.5 reference: a GUI for Python

    The detail part of an event pattern for a KeyPress or KeyRelease event specifies which key you’re binding. (See the Any modifier, above, if you want to get all keypresses or key releases).

    The table below shows several different ways to name keys. See Section 54.6, “Writing your handler: The Event class”, below, for more information on Event objects, whose attributes will describe keys in these same ways.

    • The .keysym column shows the “key symbol”, a string name for the key. This corresponds to the .keysym attribute of the Event object.
    • The .keycode column is the “key code.” This identifies which key was pressed, but the code does not reflect the state of various modifiers like the shift and control keys and the NumLock key. So, for example, both a and A have the same key code.
    • The .keysym_num column shows a numeric code equivalent to the key symbol. Unlike .keycode , these codes are different for different modifiers. For example, the digit 2 on the numeric keypad (key symbol KP_2 ) and the down arrow on the numeric keypad (key symbol KP_Down ) have the same key code (88), but different .keysym_num values (65433 and 65458, respectively).
    • The “Key” column shows the text you will usually find on the physical key, such as tab .

    There are many more key names for international character sets. This table shows only the “Latin-1” set for the usual USA-type 101-key keyboard. For the currently supported set, see the manual page for Tk keysym values.

    .keysym .keycode .keysym_num Key
    Alt_L 64 65513 The left-hand alt key
    Alt_R 113 65514 The right-hand alt key
    BackSpace 22 65288 backspace
    Cancel 110 65387 break
    Caps_Lock 66 65549 CapsLock
    Control_L 37 65507 The left-hand control key
    Control_R 109 65508 The right-hand control key
    Delete 107 65535 Delete
    Down 104 65364
    End 103 65367 end
    Escape 9 65307 esc
    Execute 111 65378 SysReq
    F1 67 65470 Function key F1
    F2 68 65471 Function key F2
    Fi 66+i 65469+i Function key F i
    F12 96 65481 Function key F12
    Home 97 65360 home
    Insert 106 65379 insert
    Left 100 65361
    Linefeed 54 106 Linefeed ( control-J )
    KP_0 90 65438 0 on the keypad
    KP_1 87 65436 1 on the keypad
    KP_2 88 65433 2 on the keypad
    KP_3 89 65435 3 on the keypad
    KP_4 83 65430 4 on the keypad
    KP_5 84 65437 5 on the keypad
    KP_6 85 65432 6 on the keypad
    KP_7 79 65429 7 on the keypad
    KP_8 80 65431 8 on the keypad
    KP_9 81 65434 9 on the keypad
    KP_Add 86 65451 + on the keypad
    KP_Begin 84 65437 The center key (same key as 5) on the keypad
    KP_Decimal 91 65439 Decimal ( . ) on the keypad
    KP_Delete 91 65439 delete on the keypad
    KP_Divide 112 65455 / on the keypad
    KP_Down 88 65433 ↓ on the keypad
    KP_End 87 65436 end on the keypad
    KP_Enter 108 65421 enter on the keypad
    KP_Home 79 65429 home on the keypad
    KP_Insert 90 65438 insert on the keypad
    KP_Left 83 65430 ← on the keypad
    KP_Multiply 63 65450 × on the keypad
    KP_Next 89 65435 PageDown on the keypad
    KP_Prior 81 65434 PageUp on the keypad
    KP_Right 85 65432 → on the keypad
    KP_Subtract 82 65453 — on the keypad
    KP_Up 80 65431 ↑ on the keypad
    Next 105 65366 PageDown
    Num_Lock 77 65407 NumLock
    Pause 110 65299 pause
    Print 111 65377 PrintScrn
    Prior 99 65365 PageUp
    Return 36 65293 The enter key ( control-M ). The name Enter refers to a mouse-related event, not a keypress; see Section 54, “Events”
    Right 102 65363
    Scroll_Lock 78 65300 ScrollLock
    Shift_L 50 65505 The left-hand shift key
    Shift_R 62 65506 The right-hand shift key
    Tab 23 65289 The tab key
    Up 98 65362

    Источник

    Пожалуйста скиньте все названия клавиш в библиотеке keyboard

    Например: ‘1’, ‘q’, ‘enter’, ‘backspace’, ‘space’, ‘ctrl’ и так далее. И как обозначается ‘[‘/’х’ или ‘]’/’ъ’?

    В keyboard-shortcut нету клавиш shift и alt
    Инструмент eliptical marque (эллиптическое выделение) сначала при нажатой клавише alt рисуется из.

    Python keyboard.add_hotkey(): как правильно сохранить значения горячих клавиш?
    В одном из приложений на библиотеке keyboard, пытаюсь реализовать установку и последующее.

    Скиньте пожалуйста документацию
    Доброго времени суток! Скиньте пожалуйста локальную документацию по qt, которую можно скачать. .

    Скиньте компилятор cl пожалуйста
    Вечер добрый. Если у кого установлена visual studio, поделитесь пж компилем от неё и нужными dll.

    Эксперт Python

    Лучший ответ

    Сообщение было отмечено whnnaayaa как решение

    Решение

    Читай документацию и исходный код — там все есть.

    Скиньте пожалуйста dclsockets100. bpl
    В папке бин не смог найти dclsockets100. bpl скинте у кого ест

    Скиньте пожалуйста adoconnection компонент
    Скиньте пожалуйста бинку для adoconnection у меня в бин папке его нету

    Скиньте пак ошибок пожалуйста
    Мне нужен пак для создания ошибок в стиле Windows 7(Кнопки, диалоговое окно, шрифты, значки).

    Странные непонятные названия в библиотеке JSoup
    Учусь парсить сайты на java и решил использовать jsoup (он точно лучший для данной задачи?) при.

    Пожалуйста. Скиньте готовый код задачи пж
    Трикутник задано координатами вершин А( ; ) , В(і;і+1) та С(-і;і+1),де і-номер варіанту.

    Нужны атрибуты bootfiles_x86, скиньте пожалуйста
    Слетел загрузчик с вин 7, когда устанавливал убунти. Сижу с убунти и ищу bootfiles_x86, не как не.

    Источник

Оцените статью