3 Modifiers
= {'lctrl', 'rctrl', 'lalt', 'ralt', 'lshift', 'rshift', 'lgui', 'rgui'}
5 function App
.keypressed(key
, scancode
, isrepeat
)
6 if array
.find(Modifiers
, key
) then
7 -- do nothing when the modifier is pressed
10 -- include the modifier(s) when the non-modifer is pressed
11 App
.keychord_press(App
.combine_modifiers(key
), key
)
14 function App
.combine_modifiers(key
)
16 if App
.ctrl_down() then
19 if App
.alt_down() then
22 if App
.shift_down() then
23 result
= result
..'S-' -- don't try to use this with letters/digits
25 if App
.cmd_down() then
32 function App
.any_modifier_down()
33 return App
.ctrl_down() or App
.alt_down() or App
.shift_down() or App
.cmd_down()
36 function App
.ctrl_down()
37 return App
.modifier_down('lctrl') or App
.modifier_down('rctrl')
40 function App
.alt_down()
41 return App
.modifier_down('lalt') or App
.modifier_down('ralt')
44 function App
.shift_down()
45 return App
.modifier_down('lshift') or App
.modifier_down('rshift')
48 function App
.cmd_down()
49 return App
.modifier_down('lgui') or App
.modifier_down('rgui')
52 function App
.is_cursor_movement(key
)
53 return array
.find({'left', 'right', 'up', 'down', 'home', 'end', 'pageup', 'pagedown'}, key
)
58 function array
.find(arr
, elem
)
59 if type(elem
) == 'function' then
60 for i
,x
in ipairs(arr
) do
66 for i
,x
in ipairs(arr
) do
75 function array
.any(arr
, f
)
76 for i
,x
in ipairs(arr
) do