about summary refs log tree commit diff stats
path: root/keychord.lua
blob: 1e319dd98125af2f38a0dff3acd98111651bb9b4 (plain) (blame)
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
-- Keyboard driver

function App.keypressed(key, scancode, isrepeat)
  if key == 'lctrl' or key == 'rctrl' or key == 'lalt' or key == 'ralt' or key == 'lshift' or key == 'rshift' or key == 'lgui' or key == 'rgui' then
    -- do nothing when the modifier is pressed
  end
  -- include the modifier(s) when the non-modifer is pressed
  App.keychord_pressed(App.combine_modifiers(key))
end

function App.combine_modifiers(key)
  local result = ''
  local down = love.keyboard.isDown
  if down('lctrl') or down('rctrl') then
    result = result..'C-'
    print(result)
  end
  if down('lalt') or down('ralt') then
    result = result..'M-'
  end
  if down('lgui') or down('rgui') then
    result = result..'S-'
  end
  result = result..key
  return result
end