Skip to content

keyboard

keyboard

Keyboard polling and text input.

keydown and keyup callbacks (see events) tell you about edges. For things that should keep happening while a key is held, ask isKeyDown each frame.

toKey

proc toKey(sc: SDL_Scancode): Key

The nim2d Key for an SDL scancode, or Key.unknown if it has no name here.

Parameters

  • sc (SDL_Scancode)

Returns

Key

keyScancode

proc keyScancode(key: Key): SDL_Scancode

The SDL scancode for a Key, the inverse of toKey.

Parameters

  • key (Key)

Returns

SDL_Scancode

isKeyDown

proc isKeyDown(scancode: SDL_Scancode): bool

Whether a physical key is currently held down, by SDL scancode.

Parameters

  • scancode (SDL_Scancode)

Returns

bool

isDown

proc isDown(key: Key): bool

Whether key is currently held down. The friendly form of isKeyDown.

Parameters

  • key (Key)

Returns

bool

startTextInput

proc startTextInput(nim2d: Nim2d)

Begin receiving textinput events for typed characters.

Parameters

  • nim2d (Nim2d)

stopTextInput

proc stopTextInput(nim2d: Nim2d)

Stop receiving textinput events.

Parameters

  • nim2d (Nim2d)
Generated with mkdocstrings-nim