Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML jQuery Basics (2014) Creating a Password Confirmation Form Perform: Part 1

JAKZ AIZZAT
JAKZ AIZZAT
7,813 Points

What's different between this?

What's different between keypress ,keyup and keydown?

Its looks same

2 Answers

Michael Hulet
Michael Hulet
47,912 Points

keyup triggers when the user lets their finger off of a key, keydown triggers when the user presses a key, and keypress fired when a user presses a key, but keypress excludes keys that don't print anything to the screen, like the shift or esc

JAKZ AIZZAT
JAKZ AIZZAT
7,813 Points

So, keyup when user finish insert key, keydown when user entering key, keypress same with keydown but not include key that doesnt show on screen(Ctrl,alt, and etc)

Michael Hulet
Michael Hulet
47,912 Points

Yes. For example, using keyup, if you held down on a key, the code you wanted to run wouldn't run until you let go of the key, but the code will run as soon as you put your finger on the key if you use keydown. keypress works exactly the same as keydown, except it includes non-printing keys like Shift or esc

JAKZ AIZZAT
JAKZ AIZZAT
7,813 Points

Thanks for your explanation :D I understand now.