As far as I know, these are the only keys that react when a button has focus.
Pressing Enter instantly 'clicks' the button, even if you keep it the key down. (So the 'click' happens on KeyDown).
Pressing Space acts more like a normal mouse click; holding it down doesn't activate the Click event, but it does once you release it. (So the 'click' happens on KeyUp or KeyPressed.)
Why the difference? I'd like a good article on the subject or simply a logical explanation as to why those two keys have different behavior. Surely there's an explanation out there!
It works correctly if ENTER is pressed on the keyboard to separate each number during input whereas on using SPACE it doesn't stop the input process.
Pressing Enter instantly 'clicks' the button, even if you keep it the key down. (So the 'click' happens on KeyDown). Pressing Space acts more like a normal mouse click; holding it down doesn't activate the Click event, but it does once you release it. (So the 'click' happens on KeyUp or KeyPressed.)
The space bar, spacebar, blank, or space key Space bar is a key on a typewriter or alphanumeric keyboard in the form of a horizontal bar in the lowermost row, significantly wider than all other keys. Its main purpose is to conveniently enter a space, e.g., between words during typing.
I can't find any articles explaining this and it's a really good question. I personally think that it's for functionality purposes
Enter Key the classic AcceptButton
acts like a FullClick
(Click/ClickReleased) that's why if you hold it you will have the effect of clicking multiple times.
Space however is a SingleClick
(No click release until you release the key) so it can accomplish task where only a Click
is required without a ClickRelease
and actions where only the selection of a control is required to activate it. Like the CheckBox
or RadioButtons
which can't be activate with the Enter but can be activated with the Space like if you click on it.
In conclusion, the Space would be the official MouseClick
since it has the same effects of a MouseClick
uppon pressing or releasing. Enter would be sort of a shortcut for a One click full click. All, of course, in the idea of giving more possibilities to the keyboard itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With