:mod:`pygame2.sdl.keyboard` -- SDL keyboard I/O wrapper module
==============================================================

SDL keyboard I/O wrapper module

.. module:: pygame2.sdl.keyboard
   :synopsis: SDL keyboard I/O wrapper module

Module Functions
----------------
.. function:: enable_repeat (delay, interval) -> None

  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 :const:`KEYDOWN` events are sent through the event queue, using
  the specified *interval*.

  Setting *delay* to 0 will disable repeating completely.



.. function:: enable_unicode ([enable]) -> bool

  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.



.. function:: get_key_name (key) -> str

  Get the descriptive name for a key constant.



.. function:: get_mod_state () -> int

  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 :mod:`pygame2.sdl.constants` module.



  **Example:** ::
    
    ...
    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")
    ...
    

.. function:: get_repeat () -> int, int

  Gets the currently set keyboard repeat delay and interval.



.. function:: get_state () -> dict

  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.



.. function:: set_mod_state (mod) -> None

  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
  :mod:`pygame2.sdl.constants` module.



  **Example:** ::
    
    ...
    import pygame2.sdl.keyboard as keyboard
    import pygame2.sdl.constants as constants
    ...
    
    # Enable numlock.
    keyboard.set_mod_state (constants.KMOD_NUM)
    ...
    


