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

@ -390,6 +390,22 @@ function input_key_label(k: int) -> string {
if k == 129 { return "Down" }
if k == 130 { return "Left" }
if k == 131 { return "Right" }
# the keys that type nothing on any layout, so there is no character to show: the name is
# the same everywhere, which is why it is not asked of the layout
if k >= 132 and k <= 143 { return "F" + string(k - 131) }
if k == 144 { return "Home" }
if k == 145 { return "End" }
if k == 146 { return "PageUp" }
if k == 147 { return "PageDown" }
if k == 148 { return "Insert" }
if k == 149 { return "Delete" }
if k == 150 { return "CapsLock" }
if k >= 152 and k <= 161 { return "Num " + string(k - 152) }
if k == 162 { return "Num *" }
if k == 163 { return "Num +" }
if k == 164 { return "Num -" }
if k == 165 { return "Num ." }
if k == 166 { return "Num /" }
var c = 0
if is_windowed() { c = win_key_char(k) }
if c <= 0 and k > 32 and k < 127 {