The platform gave these keys no code at all, so a game's rebinding screen could not take one and nothing said why. Windows asked the active layout what they type and got nothing (w_vk_char answers 0 for a key with no character); macOS let them fall through to charactersIgnoringModifiers, which reports NSF1FunctionKey and its neighbours at 0xF704 and up - outside the 256-bit held set either way. w_keyval and ev_keyval now name them, with the same codes on both: 132-143 F1-F12, 144-149 Home / End / PageUp / PageDown / Insert / Delete, 150 Caps Lock, 152-161 the numpad digits, 162-166 its * + - . and /. The numpad's Enter is Enter. Key.F1, Key.Home, Key.Numpad0 and the rest fold at compile time, and Input.key_label names them without asking the layout - a key that types nothing is called the same thing on every layout. examples/library/input_typeless_keys.ludic covers the codes, the names, the held set and the press edge; 150 passed in ludic-dev test, 33 in selfhost-test. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1.2 KiB
1.2 KiB
| id | name | category | kind | tokens | sig | tip | order | ns | member |
|---|---|---|---|---|---|---|---|---|---|
| input-key_down | Input.key_down | input | namespace-method | Input.key_down | Input.key_down(key) -> bool | Is a physical key held this frame? | 8 | Input | key_down |
Returns whether a physical key is held this frame — from the platform when windowed, from the polled key when headless, and from Input.press injection on any target. Unlike the single-key Input.down, several keys can be held at once (move left and jump). Every key on the keyboard has a code: letters, digits and punctuation are their US-layout character, Space, Enter, Esc, Tab, Backspace, Shift, Ctrl and Alt their usual ones, the arrows 128-131, and the keys that type nothing 132-166 - F1-F12 at 132, Home, End, PageUp, PageDown, Insert and Delete at 144, Caps Lock at 150, the numpad digits at 152 and its *, +, -, . and / at 162. Key.F1, Key.Home and Key.Numpad0 name them.
program Demo {
entry {
Input.press('a')
Input.poll()
if Input.key_down('a') { print(1) }
}
}