jQuery: 22 - Detecting a keyboard event

Опубликовано: 01 Ноябрь 2024
на канале: Meray Tutorials
177
3

It can be useful to detect when a key on the keyboard is pressed by someone visiting your site.

The following events are associated with the keyboard, and you can attach events to any of them:

✓ keydown: A key is pressed.

✓ keyup: A pressed key is released.

✓ keypress: A key is pressed and released.

The keydown event takes place before the keyup event If someone holds down a key and doesn’t release it, the keydown event takes place.

If someone presses a key and releases it, a keypress takes place. Every key on the keyboard is associated with a numeric value. For example, A equals 65, B equals 66, and Z equals 90.

These numbers are called ASCII values. You can see a chart of these values at www.ascii.cl. Now that we know these values, we can detect when a particular letter key is pressed.

I'm Junaid, partial blogger and SEO speaker along with programmer :) Creating tutorials is fun, and I'm on the way don't forget to join me on other social media.

Website: http://wikia.pk

  / junaidshahidofficial  
https://plus.google.com/+JunaidShahid1
  / mrjunaidshahid  

Blog:
https://junaidshahid.com

Keyword Rank Videos:
http://bit.ly/2rRpphr

How Do You Do Blogging Series:
http://bit.ly/2s4iAsR

JavaScript Tutorials
http://bit.ly/2zMEplJ

CSS Tutorials
http://bit.ly/2iwx5GO

HTML Tutorials
http://bit.ly/2gEkv7E