Keyboard API

Functions for simulating keyboard input.


get_special_table

get_special_table()

Returns the special keyboard keys table for the current platform.

Returns:

Dictionary of special key names to key codes.

Return type:

dict

Note

Not every platform has special keys.


get_keyboard_keys_table

get_keyboard_keys_table()

Returns the full keyboard keys table for the current platform.

Returns:

Dictionary of key names to key codes.

Return type:

dict


press_keyboard_key

press_keyboard_key(keycode, is_shift=False, skip_record=False)

Presses and holds a keyboard key. Use release_keyboard_key() to release it.

Parameters:
  • keycode (int or str) – Key name or key code to press.

  • is_shift (bool) – Whether to press Shift simultaneously.

  • skip_record (bool) – If True, this action will not be recorded.

Returns:

The key code that was pressed.

Return type:

str


release_keyboard_key

release_keyboard_key(keycode, is_shift=False, skip_record=False)

Releases a previously pressed keyboard key.

Parameters:
  • keycode (int or str) – Key name or key code to release.

  • is_shift (bool) – Whether Shift was pressed.

  • skip_record (bool) – If True, this action will not be recorded.

Returns:

The key code that was released.

Return type:

str


type_keyboard

type_keyboard(keycode, is_shift=False, skip_record=False)

Presses and immediately releases a keyboard key.

Parameters:
  • keycode (int or str) – Key name or key code to type.

  • is_shift (bool) – Whether to press Shift simultaneously.

  • skip_record (bool) – If True, this action will not be recorded.

Returns:

The key code that was typed.

Return type:

str


check_key_is_press

check_key_is_press(keycode)

Checks whether a specific key is currently pressed.

Parameters:

keycode (int or str) – Key name or key code to check.

Returns:

True if the key is pressed, False otherwise.

Return type:

bool