Detect arrow keypress in JavaScript

Sometimes we need to detect the arrow key presses in our JavaScript web apps.

In this article, we’ll look at how to detect arrow key presses in JavaScript.

Detecting arrow key presses in JavaScript

function checkKey(e) {
    var event = window.event ? window.event : e;
    console.log(event.keyCode)
}

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top