Actually this is better:
var code = e.keyCode || e.which;
if(code == 13) { //Enter keycode
//Do something
}
More Related Contents:
- Definitive way to trigger keypress events with jQuery
- Changing the keypress
- jquery keypress event object keyCode for firefox problem?
- How do I attach events to dynamic HTML elements with jQuery? [duplicate]
- jQuery .live() vs .on() method for adding a click event after loading dynamic html
- How to set file input value when dropping file on page? [duplicate]
- Detecting Browser Autofill
- jQuery how to bind onclick event to dynamically added HTML element [duplicate]
- JavaScript / jQuery: Test if window has focus
- How to stop event bubbling on checkbox click
- ‘this’ does not work properly in another event. I’m clueless as to why [duplicate]
- jQuery equivalent of JavaScript’s addEventListener method
- prevent Scroll bubbling from element to window
- Get index of clicked element in collection with jQuery
- How to stop default link click behavior with jQuery
- Listening for Youtube Event in JavaScript or jQuery
- Throttle event calls in jQuery
- JavaScript: DOM load events, execution sequence, and $(document).ready()
- how to move a div with arrow keys
- How can I get jQuery .val() AFTER keypress event?
- jQuery Mobile : What is the order of page events triggering?
- How to know if .keyup() is a character key (jQuery)
- How do I handle a click anywhere in the page, even when a certain element stops the propagation?
- Event propagation in Javascript
- jQuery – How can I temporarily disable the onclick event listener after the event has been fired?
- How do I capture a key press (or keydown) event on a div element?
- How to disable mouseout events triggered by child elements?
- jquery/javascript: function(e){…. what is e? why is it needed? what does it actually do/accomplish?
- Prototype equivalent for jQuery live function
- Unloading/Removing content from an iFrame