SDL keyboard I/O wrapper module
Enables or disables the keyboard repeat rate.
Enables or disables the keyboard repeat rate. delay specifies how long a key must be pressed before the repeat begins. interval is the speed with which it repeats. delay and interval are expressed as milliseconds. Thus, after the initial delay has passed, repeated KEYDOWN events are sent through the event queue, using the specified interval.
Setting delay to 0 will disable repeating completely.
Enables or disables unicode input handling.
Enables or disables unicode input handling. If the argument is omitted, the function will return the current unicode handling state.
By default unicode handling is enabled and for keyboard events, the unicode member of the event will be filled with the corresponding unicode character.
Returns the current state of the modifier keys (CTRL, ALT, etc.).
Returns a single integer representing a bitmask of all the modifier keys being held. Using bitwise operators you can test if specific shift keys are pressed, the state of the capslock button, and more.
The bitmask will consist of the various keyboard modifier flags as specified in the pygame2.sdl.constants module.
...
import pygame2.sdl.keyboard as keyboard
import pygame2.sdl.constants as constants
...
# Check, whether any control ar alt key was pressed.
if (keyboard.get_mod_state () & (constants.KMOD_CTRL | constants.KMOD_ALT)) != 0:
print ("A control or alt key is pressed")
...
Gets the current keyboard state.
Gets a dictionary with the current keyboard state. The keys of the dictionary are the key constants, the boolean values of the dictionary indicate, whether a certain key is pressed or not.
Sets the current modifier key state.
Sets the current modifier key state. mod has to be a bitwise OR’d combination of the keyboard modifier flags as specified in the pygame2.sdl.constants module.
...
import pygame2.sdl.keyboard as keyboard
import pygame2.sdl.constants as constants
...
# Enable numlock.
keyboard.set_mod_state (constants.KMOD_NUM)
...