|
Size: 2789
Comment: update content - add intro from Stuart Bentley
|
Size: 2648
Comment: update content - w/ Sam
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 16: | Line 16: |
| This category contains functions for handling keyboard inputs. ^Keysym and scancode information is included in this section for convenience.^ | This category contains functions for handling keyboard inputs. SDL uses two different types of values to represent keys on the keyboard - scancode and keycode. |
| Line 20: | Line 20: |
| [[SDL_Keycode]] values (also known as keycodes or keysyms) are mapped to the current layout of the keyboard and correlate to an [[SDL_Scancode]]. Values of this type are used to represent key symbols in the `key.keysym.sym` field of the [[SDL_Event]] structure, among other places. The values in the [[SDL_Keycode]] enumeration are based on Unicode values representing the unmodified character that would be generated by pressing the key, or the scancode value with the high bit set (bitwise ANDed with 0x8000000) for those keys that do not generate characters. | [[SDL_Keycode]] values are mapped to the current layout of the keyboard and correlate to an [[SDL_Scancode]]. Values of this type are used to represent key symbols in the `key.keysym.sym` field of the [[SDL_Event]] structure, among other places. The values in the [[SDL_Keycode]] enumeration are based on Unicode values representing the unmodified character that would be generated by pressing the key, or the scancode value with the high bit set (bitwise ANDed with 0x8000000) for those keys that do not generate characters. |
| Line 25: | Line 25: |
The name of a key can be obtained using [[SDL_GetKeyName]] for the keycode or [[SDL_GetScancodeName]] for the scancode. |
DRAFT |
Keyboard Support
Include File(s): SDL_keyboard.h, SDL_keysym.h, SDL_scancode.h
Introduction
This category contains functions for handling keyboard inputs. SDL uses two different types of values to represent keys on the keyboard - scancode and keycode.
SDL_Scancode values are used to represent the physical location of a keyboard key on the keyboard. Values of this type are used to represent keyboard keys in the key.keysym.scancode field of the SDL_Event structure, among other places. The values in the SDL_Scancode enumeration are based on the USB usage page standard (http://www.usb.org/developers/devclass_docs/Hut1_12.pdf).
SDL_Keycode values are mapped to the current layout of the keyboard and correlate to an SDL_Scancode. Values of this type are used to represent key symbols in the key.keysym.sym field of the SDL_Event structure, among other places. The values in the SDL_Keycode enumeration are based on Unicode values representing the unmodified character that would be generated by pressing the key, or the scancode value with the high bit set (bitwise ANDed with 0x8000000) for those keys that do not generate characters.
The main difference between these two values comes into play in situations where the operating system is mapping the physical keyboard keys to different virtual letters. For instance, when a standard QWERTY keyboard is mapped to a German QWERTZ layout, the "Y" key will generate events with a scancode of SDL_SCANCODE_Y, but a keycode of SDLK_z. Which one to use is left to the application: scancodes are suited in situations where controls are layout-dependent (eg. the "WASD" keys as left-handed arrow keys), whereas keycodes are better suited to situations where controls are character-dependent (eg. the "I" key for Inventory).
Scancode constants use the symbol name prefixed with SDL_SCANCODE_. Keycode constants use the symbol name (lowercased for letters) prefixed with SDLK_.
Enumerations
Structures
Functions
- SDL_GetKeyFromName
- SDL_GetKeyFromScancode
- SDL_GetKeyName
- SDL_GetKeyboardFocus
- SDL_GetKeyboardState
- SDL_GetModState
- SDL_GetScancodeFromKey
- SDL_GetScancodeFromName
- SDL_GetScancodeName
- SDL_HasScreenKeyboardSupport
- SDL_IsScreenKeyboardShown
- SDL_IsTextInputActive
- SDL_SetModState
- SDL_SetTextInputRect
- SDL_StartTextInput
- SDL_StopTextInput
