about summary refs log blame commit diff stats
path: root/keychord.lua
blob: d9b89f5581f2ab3f3191e823b1906b9bf4c9b47e (plain) (tree)
























                                                                                                                                                    
-- Keyboard driver

function love.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
  keychord_pressed(combine_modifiers(key))
end

function combine_modifiers(key)
  local result = ''
  local down = love.keyboard.isDown
  if down('lctrl') or down('rctrl') then
    result = result..'C-'
  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