sdl2-2.1.0: Both high- and low-level bindings to the SDL library (version 2.0.3).

Safe HaskellSafe
LanguageHaskell2010

SDL.Input.Keyboard.Codes

Contents

Description

An enumeration of scancodes and keycodes, allowing you to pattern match on keyboard keys.

This module uses a relatively new GHC feature called PatternSynonyms in order to provide pattern matches over the underlying Scancode or Keycode. We do this so that you are also able to work with vendor-specific or otherwise unknown codes.

Synopsis

Scancodes

Scancodes are codes that correspond to the physical position of a key, independent of the current keyboard layout. Scancodes are meant to be layout-independent. Think of this as "the user pressed the Q key as it would be on a US QWERTY keyboard" regardless of whether this is actually a European keyboard or a Dvorak keyboard or whatever. The scancode is always the same key position. Scancode makes sense when you want key presses based on their location on a keyboard - for example, the traditional "WASD" layout used in first-person shooters.

Keycode

Keycodes are layout-dependent codes, in that the code you receive can change for the same physical key depending on the users keyboard layout. Think of this as "the user pressed the key that is labelled Q on a specific keyboard." Keycode makes sense when you are anticipating the user to press either keys that match some mneumonic, or they are entering text.