class Keyboard {
	constructor() {
		this.keys = {}
		this.pressed = {}

		this.init()
	}

	init() {
		window.addEventListener(
			'keydown',
			({ code }) => {
				// console.log(code)

				this.pressed[code] = !this.keys[code]
				this.keys[code] = true
			},
			true
		)

		window.addEventListener(
			'keyup',
			({ code }) => {
				this.keys[code] = false
			},
			true
		)
	}

	process() {
		Object.keys(this.pressed).forEach(key => (this.pressed[key] = false))
	}
}

export default new Keyboard()
