Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to detect which key is pressed in javascript

$(this).keypress((e) => {
  if (e.key === "a") alert("you pressed a");
  else alert("you pressed " + e.key);
});
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #detect #key #pressed #javascript
ADD COMMENT
Topic
Name
7+4 =