Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

i wanted to detect when a user enters an alphabet key in input text javascript

document.addEventListener('keyup', event => {
  if (String.fromCharCode(event.keyCode).match(/(w|s)/g)) {
    //pressed key is a char
  } else {
    //pressed key is a non-char
    //e.g. 'esc', 'backspace', 'up arrow'
  }
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #wanted #detect #user #enters #alphabet #key #input #text #javascript
ADD COMMENT
Topic
Name
6+8 =