feat: every key on the keyboard is bindable - the F-row, the six-pack, Caps Lock and the numpad

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>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-18 00:57:02 +03:00
parent 9dfa2951f6
commit 4979cc0c94
11 changed files with 21327 additions and 20462 deletions

View file

@ -0,0 +1,38 @@
# input_typeless_keys.ludic — the keys that type no character: the F-row, the six-pack,
# Caps Lock and the numpad. Until 0.22 the platform gave them no code at all - Windows
# asked the layout what they type and got nothing, macOS got NSF1FunctionKey (0xF704 and
# up, outside the 256-bit held set) - so a game could not bind one and nothing said why.
# They are codes 132-166 now, the same on both, with a name that is not asked of the
# layout because it is the same on every layout.
#
# Deterministic; a full run prints: 132 143 144 149 150 152 161 F1 F12 Home Delete CapsLock Num 0 Num / 1 0 1
program InputTypelessKeys {
function bi(b: bool) -> int { if b { return 1 }; return 0 }
entry {
print(Key.F1)
print(Key.F12)
print(Key.Home)
print(Key.Delete)
print(Key.CapsLock)
print(Key.Numpad0)
print(Key.Numpad9)
print(Input.key_label(Key.F1))
print(Input.key_label(Key.F12))
print(Input.key_label(Key.Home))
print(Input.key_label(Key.Delete))
print(Input.key_label(Key.CapsLock))
print(Input.key_label(Key.Numpad0))
print(Input.key_label(Key.NumpadDivide))
Input.press(Key.F5) # hold F5
Input.poll()
print(bi(Input.key_down(Key.F5))) # 1 — it is in the held set like any other key
print(bi(Input.key_down(Key.F6))) # 0 — and only that one
Input.release(Key.F5)
Input.press(Key.PageDown)
Input.poll()
print(bi(Input.key_pressed(Key.PageDown))) # 1 — the edge fires for it too
}
}