Map en action

const allowedKeys = new Map([
        [37, 'left'],
        [38, 'up'],
        [39, 'right'],
        [40, 'down']
]);
document.addEventListener('keydown', function(e) {
 let arrow = allowedKeys.get(e.keyCode);
    if (arrow) document.querySelector("#Key").innerHTML +=`<br/>${arrow}`;
    e.preventDefault();
    return false;
});


JS Bin on jsbin.com