about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--keychord.lua37
1 files changed, 37 insertions, 0 deletions
diff --git a/keychord.lua b/keychord.lua
index 16fa48d..f1b6a59 100644
--- a/keychord.lua
+++ b/keychord.lua
@@ -12,6 +12,11 @@ function App.keypressed(key, scancode, isrepeat)
 end
 
 function App.combine_modifiers(key)
+  if love.keyboard.isModifierActive then  -- waiting for LÖVE v12
+    if key:match('^kp') then
+      key = App.translate_numlock(key)
+    end
+  end
   local result = ''
   if App.ctrl_down() then
     result = result..'C-'
@@ -53,6 +58,38 @@ function App.is_cursor_movement(key)
   return array.find({'left', 'right', 'up', 'down', 'home', 'end', 'pageup', 'pagedown'}, key)
 end
 
+-- mappings only to non-printable keys; leave out mappings that textinput will handle
+Numlock_off = {
+  kp0='insert',
+  kp1='end',
+  kp2='down',
+  kp3='pagedown',
+  kp4='left',
+  -- numpad 5 translates to nothing
+  kp6='right',
+  kp7='home',
+  kp8='up',
+  kp9='pageup',
+  ['kp.']='delete',
+  -- LÖVE handles keypad operators in textinput
+  -- what's with the `kp=` and `kp,` keys? None of my keyboards have one.
+  -- Hopefully LÖVE handles them as well in textinput.
+  kpenter='enter',
+  kpdel='delete',
+}
+Numlock_on = {
+  kpenter='enter',
+  kpdel='delete',
+}
+function App.translate_numlock(key)
+  if love.keyboard.isModifierActive('numlock') then
+    return Numlock_on[key] or key
+  else
+    return Numlock_off[key] or key
+  end
+  return key
+end
+
 array = {}
 
 function array.find(arr, elem)
subx/034compute_segment_address.cc.html?h=main&id=08a0eed699b8ea07d37163aba610c8e04feee003'>08a0eed6 ^
e4ac3c9e ^
ac07e589 ^

ce2c1efc ^

ac07e589 ^

ce2c1efc ^
608a7fa8 ^















ce2c1efc ^
608a7fa8 ^















c8a3ccbe ^
608a7fa8 ^
52daf072 ^








c8a3ccbe ^
52daf072 ^



695f9bf8 ^
52daf072 ^












c8a3ccbe ^
52daf072 ^



c8a3ccbe ^


52daf072 ^


695f9bf8 ^
c8a3ccbe ^
52daf072 ^







c8a3ccbe ^

52daf072 ^





c8a3ccbe ^

52daf072 ^


























608a7fa8 ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148