KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
What am I doing wrong here? The idea is that I can separate the arrow key presses from anything else, but the every key press is firing the alert 'you pressed an arrow key'. Any help would be great! jsFiddle here or: <input id='foo'> <script> $('#foo').keyup(function (e) { var key = e.keyCode; if ($.inArray(key, [37, 38, 39, 40])) { alert('you pressed an arrow key'); } else { alert("you didn't press an arrow key"); } }); </script>
Tags (comma-separated)
Save Edits
Cancel