I’d just like to hear an explanation of why it is. Because if you handled “is key currently pressed” events with polling rather than events (which is how people almost always consume them logically), it would be the only thing in the entire world that I can think of that would/should use keyup.

Edit: I think people are misunderstanding me. I’m asking for an explanation of why, when you have a button focused, pressing Space activates on key up, rather than key down like literally everything else on the keyboard, including Enter on a focused button. (Mouse activates on release.)

Because in those contexts, the Space key is being used as a physical mirror of the on-screen button, and on-screen buttons are UX'd to perform action when released.

These two interactions should behave identically:

- Hover over a button, press mouse button 1, release button 1.

- Tab over to a button, press spacebar, release spacebar.

Why on-screen buttons are UX'd to behave this way is a logical follow-up question. I'd wager that it gives a means to bail out of the clicking (e.g. by moving the mouse out of the on-screen button before releasing mousebutton 1, or by pressing Esc while having spacebar still depressed).

Yes, the bailing-out explanation is right. With a mouse it's intentional that you should be able to push the pointer off the button with the mouse button still pressed to cancel.

(Esc while Space is held doesn’t cancel, but Tab does.)

You’re only answering half of the inconsistency: because Enter activates buttons like any other key, on keydown.

Just diving in without full context, but, enter is often a completion action. Historically often a full carriage return. It often means "submit data".

So this could be the oddity

It just matches real life. What about lmb to shoot? You don't fire a gun on trigger release, you fire it on trigger down. Walking? Would be weird moving only on keyup.

This raises the question of why real life buttons and virtual buttons behave differently. My unsubstantiated guess is that clicks act on release to give the opportunity to slide off the button to abort, and/or because the button would disappear while pressing if it ex. submits a form.

Jump is keydown because many games let you adjust your jump height based on how long you hold down space after the jump starts.

Games use keydown because it is more responsive and control responsiveness is vital to dynamic gameplay feeling good. There are some exceptions - if action can be charged, then it is on keydown. And then on gamepad sometimes actions are on release when developer has too many actions and not enough buttons, so it can be keyup vs hold.

I may be wrong on this, but I think that pressing esc while space is held down cancels the button press, like moving the mouse off the key while holding down the click does. I'd need to test this, though.