The keyup event is fired when a key is released.
The keydown and keyup events provide a code indicating which key is pressed, while keypress indicates which character was entered. For example, a lowercase "a" will be reported as 65 by keydown and keyup, but as 97 by keypress. An uppercase "A" is reported as 65 by all events.
The event target of a key event is the currently focused element which is processing the keyboard activity. This includes: <input>, <textarea>, anything that is contentEditable, and anything else that can be interacted with the keyboard, such as <a>, <button>, and <summary>. If no suitable element is in focus, the event target will be the <body> or the root. The event bubbles. It can reach Document and Window.
The event target might change between different key events. For example, the keydown target for pressing the Tab key would be different from the keyup target, because the focus has changed.
Because the event fires after the key is released, modifier-key properties (ctrlKey, altKey, shiftKey, and metaKey) reflect the state after release. For example, ctrlKey is false on the keyup event for the Control key itself. If another key is released while the Control key remains pressed, ctrlKey is true on that key's keyup event.