Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,842 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,842 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.