• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

confused with keydown and key press

 
Ranch Hand
Posts: 72
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
It looks like it's time for me to write you a reality check! Or maybe a tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic