document.getElementById('foo').onkeypress = function(e){
if (!e) e = window.event;
var keyCode = e.code || e.key;
if (keyCode == 'Enter'){
// Enter pressed
return false;
}
}
More Related Contents:
- How to add a dynamic query string to a link?
- How to create an object property from a variable value in JavaScript? [duplicate]
- Parse XML using JavaScript [duplicate]
- How to dynamically change header based on AngularJS partial view?
- How to change CSS property using JavaScript
- How does garbage collection work in JavaScript?
- Javascript getCookie functions
- Binding multiple events to a listener (without JQuery)?
- JavaScript runtime complexity of Array functions
- How to bind bootstrap popover on dynamic elements
- For loop through Array only shows last value
- Attaching click event to a JQuery object not yet added to the DOM [duplicate]
- if (key in object) or if(object.hasOwnProperty(key)
- Stop fixed position at footer
- Is it possible to dynamically scale text size based on browser width?
- What does “publicPath” in Webpack do?
- Example for Bubbling and Capturing in React.js
- How to launch apps (facebook/twitter/etc) from mobile browser but fall back to hyperlink if the app isn’t installed
- How to simulate typing in input field using jQuery?
- HEX to Base64 converter for JavaScript
- Submit and onclick not working together
- Accessing Express.js local variables in client side JavaScript
- How to fetch XML with fetch api
- Why does `childNodes` return a number larger than I expect?
- Remove an element from the DOM from reference to element only
- How to set up Python server side with javascript client side
- Regex: only alphanumeric but not if this is pure numeric
- Error: Permission denied to access property ‘handler’
- In Node.js / Express, how do I “download” a page and gets its HTML?
- Create a DOM document from string, without JQuery