# Working with the keyboard

pyglet has support for low-level keyboard input suitable for games as well as locale- and device-independent Unicode text entry.

Keyboard input requires a window which has focus. The operating system usually decides which application window has keyboard focus. Typically this window appears above all others and may be decorated differently, though this is platform-specific (for example, Unix window managers sometimes couple keyboard focus with the mouse pointer).

You can request keyboard focus for a window with the activate method, but you should not rely on this -- it may simply provide a visual cue to the user indicating that the window requires user input, without actually getting focus.

Windows created with the WINDOW_STYLE_BORDERLESS or WINDOW_STYLE_TOOL style cannot receive keyboard focus.

It is not possible to use pyglet's keyboard or text events without a window; consider using Python built-in functions such as `raw_input` instead.

- Keyboard events
  - Defined key symbols
  - Modifiers
  - User-defined key symbols
  - Remembering key state
- Text and motion events
  - Motion events
- Keyboard exclusivity