Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleSpellbookEvent(evt) {
let { keyCode } = evt
let shiftPressed = evt.getModifierState('Shift')
// evt.preventDefault()
const exit = [ROT.VK_ESCAPE, ROT.VK_Z, ROT.VK_S, ROT.VK_M]
const confirm = [ROT.VK_RETURN, ROT.VK_E]
const up = [ROT.VK_UP, ROT.VK_NUMPAD8, ROT.VK_W, ROT.VK_K]
const down = [ROT.VK_DOWN, ROT.VK_NUMPAD2, ROT.VK_S, ROT.VK_J]
const left = [ROT.VK_LEFT, ROT.VK_NUMPAD4, ROT.VK_H]
const right = [ROT.VK_RIGHT, ROT.VK_NUMPAD6, ROT.VK_L]
const ul = [ROT.VK_NUMPAD7, ROT.VK_Y]
const lr = [ROT.VK_NUMPAD3, ROT.VK_N]
const ur = [ROT.VK_NUMPAD9, ROT.VK_U]
const ll = [ROT.VK_NUMPAD1, ROT.VK_B]
/* If the key event isn't repeated within the last 160 milliseconds (too soon), then we proceed but we keep track of this
key movement time */
if (evt.type === 'keydown' && up.concat(down).includes(keyCode)) {
if (this.keyTimer === null) {
this.keyTimer = new Date()
} else {
let start = this.keyTimer.getTime()
document.body.addEventListener('keydown', (e) => {
if(e.keyCode !== ROT.VK_M) return;
GameState.manualMove = !GameState.manualMove;
if(!GameState.manualMove) {
GameState.game.engine.unlock();
}
});