local consts = require 'constants'
local keys = {
   pressed = {},
   released = {},
}

function keys.pressed.q(s) love.event.quit() end

function keys.pressed.w(s) s.char.dy = -consts.speed end
function keys.pressed.a(s) s.char.dx = -consts.speed end
function keys.pressed.s(s) s.char.dy = consts.speed end
function keys.pressed.d(s) s.char.dx = consts.speed end

function keys.released.w(s) s.char.dy = 0 end
function keys.released.a(s) s.char.dx = 0 end
function keys.released.s(s) s.char.dy = 0 end
function keys.released.d(s) s.char.dx = 0 end

function keys.pressed.e(s)
   local tgt = s.char:getFocus(s.board)
   if tgt then
      tgt:action(s)
   end
end

return {
   keys = keys
}
