window.addEventListener('keydown', (e) => {
let arrowsObj = {
"ArrowUp": 1,
"ArrowDown": 2,
"ArrowLeft": 3,
"ArrowRight": 4
}
let eventKey = e.key;
console.log(arrowsObj.eventKey);
});
The above code doesn't work, so I did the following checks:
arrowsObj.hasOwnProperty(eventKey)
if(eventKey in arrowsObj)
Both returning true, what have I missed? Would that be because of data type?
Thanks!