Up, Down, In-Between?

Many people get the DOM (Document Object Model) Events keypress, keydown and keyup confused, I was one of them.

At a surface level it may appear they do basically the same thing, but let’s look a little closer…

Keypress events can seem the same as keydown, but keydown is triggered as soon as a user presses a key on a keyboard. A keypress event is triggered for each character that’s typed.

For example, modifier keys like Shift, that don’t actually type a character when pressed, trigger keydown events. But because it never types a character, it never triggers a keypress event.

The keyup event is caused when the user releases a key. The element that has the focus, or often the cursor, is where the event is sent.

Love & Peace,

Danielle