JavaScript window.onkeydown without jQuery

Bind to window.onkeydown natively without jQuery.

window.onkeydown = function(event) {
    if (event.keyCode === 27) {
        console.log('escape pressed');
    }
};
Did this help you? Please let me know with a comment. Thank you
Posted .

Comments (RSS)

Leave a comment