Keyboard Down

3 minutes
Share the link to this page
Copied
  Completed
The keydown event occurs when a keyboard key is pressed down. The keydown() method triggers the keydown event, or attaches a function to run when a keydown event occurs.

Transcript

Hello, in this jQuery video, I am going to cover the key down event. So the key down event occurs when you click a key on your keyboard, but it keeps triggering, while the key is, you know, actually pressed down. So it is true, true ones. So what we're going to do is select one of these days. So we'll just do a simple selector, select the advanced for as simple as you want. The Magic here happened after the dot key down and then put function so you would with any other events.

And now here in the console dot log, hello just doing console logs simply because it's easy to tap into to see. And if I say key pressed, I say that reloads and if I click OK, so I'm going to Actually, I will need to highlight this. So it's gonna be more difficult. Let me change these inputs, that will be a much better way of doing it. And I'm going to type equals one point anybody or anything, I'm just going to assign an ID to it. Okay, I don't need an ID I can select the input directly.

Again, why the Select? Do you want to? Okay, so if I just say that now on reload, now for press a key phone Oh, I'm not actually on here. My bad as you can see, you know, constantly triggering. That's because I've got the key press and then if I let go, it stops triggering. So that's what the key then does.

If you You want to know which key is being pressed, then you just want a parameter. And what we could do is event dot which. And now if I reload go into her it's a 71. In my thinking, What's that for? Let me you know push a, it is asking. So it is the ASCII number.

So if you want to know exactly you know what it is I'll recommend opening up ASCII table and taking a look at the values for the different keys. You just need to go to what character you're looking for. So a go to decimal is 65. So that's the key An event of the next tutorial I'm gonna show you some more keyboard events to extend your application. If you have any questions, feel free to drop me a message and as usual, I look forward to seeing you in the next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.