import Game from '../core/game'

class KeyboardInput {
    constructor () {
        this.keys = {}
    }

    init () {
        window.addEventListener('keydown', evt => {
            this.keys[evt.code] = true
            Game.emit('key', this.keys)
        })

        window.addEventListener('keyup', evt => {
            this.keys[evt.code] = false
            Game.emit('key', this.keys)
        })
    }

}

export default new KeyboardInput
