I am fairly new to HTML and I'm starting a new project to help me learn, but I don't know how to detect if a specific key is being pressed and I can't think of anything.
Asked
Active
Viewed 30 times
-1
-
Does this answer your question? [Simplest way to detect keypresses in javascript](https://stackoverflow.com/questions/16089421/simplest-way-to-detect-keypresses-in-javascript) – Robert Harvey Oct 12 '20 at 19:53
-
@RobertHarvey ill try that thanks! – Julio Diaz Oct 12 '20 at 20:04
1 Answers
0
You can not detect such kind of events by using only HTML code. You have to write javascript or jquery code along with your HTML code to archive this functionality.
Below is one of the example of jQuery code where we are increasing value by 1 every time when pressing key on input field.
$("input").keypress(function(){
$("span").text(i += 1);
});
Note: if you want to learn basic, i would like to suggest w3schools.com for the same.

Vivek Jain
- 317
- 3
- 12