Module keyboard
keyboard (typing, not piano)
The norns script reference has examples for this module.
Functions
code (key, value) | key code callback, script should redefine. |
char (ch) | key character callback, script should redefine. |
shift () | return SHIFT state |
alt () | return ALT state |
ctrl () | return CTRL state |
meta () | return META state |
code_to_char (code) | convert a keyboard code to a printable character. |
Tables
state | key states |
Functions
- code (key, value)
-
key code callback, script should redefine.
use this primarily for responding to physical key presses ('LEFTSHIFT',
'ENTER', 'F7', etc) not printable characters, as it does not adjust to
the setting of the user's keyboard layout, including national variant.
if you want to detect the character, use char or code_to_char.
Parameters:
- key string a code representing the physical key pressed.
- value number 0 = released, 1 = pressed, 2 = pressed and held.
- char (ch)
-
key character callback, script should redefine.
will only be called for printable characters such as letters, numbers
and punctuation - and space. will take account of the setting of the user's keyboard
layout, including national variant.
Parameters:
- ch string the printable character intended to be generated.
- shift ()
- return SHIFT state
- alt ()
- return ALT state
- ctrl ()
- return CTRL state
- meta ()
- return META state
- code_to_char (code)
-
convert a keyboard code to a printable character.
the output will be based on the setting of they user's keyboard
layout and the state of the modifier keys currently pressed
(eg a 'SHIFT' key).
Parameters:
Returns:
-
string
a string, or nil if no conversion is possible.