Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to detect the keyboard keys in js

With plain Javascript, the simplest is:
		document.onkeypress = function (e) {
    	e = e || window.event;
    	// use e.keyCode or whatever you want
};
You can Use the following too in Plain JS:
		document.addEventListener('keypress', function (e) {
    	e = e || window.event;
        // use e.keyCode or whatever you want
});
With jQuery:
		$(document).on("keypress", function (e) {
    	// use e.which
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: object foreach 
Javascript :: how to open html file with javascript 
Javascript :: javascript init an array to 0 
Javascript :: form input field readonly angular 
Javascript :: javascript read json file 
Javascript :: js tolocalestring with hours 
Javascript :: google map react iframe 
Javascript :: javascript style text decoration 
Javascript :: generate random random number with fixed length 
Javascript :: how to detect a button click in javascript 
Javascript :: keyup multiple fields 
Javascript :: century from year javascript 
Javascript :: javascript sorting array string by len 
Javascript :: javascript print numbers in the given range 
Javascript :: select element in js 
Javascript :: fuse.js cdn 
Javascript :: identify unused node modules 
Javascript :: js animate scroll to the top of the page 
Javascript :: check if date is after or before with moment 
Javascript :: fizzbuzz js 
Javascript :: get time from a date time in jquery 
Javascript :: js does array.map maintain the order 
Javascript :: node-schedule-tz print jobs 
Javascript :: add disabled js 
Javascript :: daterangepicker change 
Javascript :: check if a string is alphanumeric 
Javascript :: remove element from array javascript 
Javascript :: adonisjs livereload 
Javascript :: react execute code after set 
Javascript :: js reverse array of objects 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =