How do I go about binding a function to left and right arrow keys in Javascript and/or jQuery? I looked at the js-hotkey plugin for jQuery (wraps the built-in bind function
You can use jQuery bind:
$(window).bind('keydown', function(e){ if (e.keyCode == 37) { console.log('left'); } else if (e.keyCode == 38) { console.log('up'); } else if (e.keyCode == 39) { console.log('right'); } else if (e.keyCode == 40) { console.log('down'); } });