Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

confused with keydown and key press

 
Ranch Hand
Posts: 72
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good day, im reading about keypress,key up and key down
key down = event will trigger after you press the key (more easy to understand based on definition and you can easily know how it works)
but im a bit confuse of key down and keypress i try to use them and it seems that they are the same based on functionality.
Just want to know more how key press and key down becomes different? thank you.
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The difference is subtle but distinct. The key press event is triggered only for keys that produce characters, whereas keydown is triggered for all keys.

You can see the difference by creating a test page that captures both events for an input. You will see that both events are triggered when a key such as Q is pressed. But what about when you press the SHIFT key? What happens differently?

 
chrstian ferma
Ranch Hand
Posts: 72
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:The difference is subtle but distinct. The key press event is triggered only for keys that produce characters, whereas keydown is triggered for all keys.

You can see the difference by creating a test page that captures both events for an input. You will see that both events are triggered when a key such as Q is pressed. But what about when you press the SHIFT key? What happens differently?




yes i see the difference of keydown and key press thank you
 
He's giving us the slip! Quick! Grab this tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic