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 dow
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.
You're seeing two different behaviors, which aren't associated except that they both deal with keyboard events on a winform.
Enter is special because it's the keypress to activate the acceptButton of a form. In fact, you missed another key that can affect buttons: Esc is the cancelButton, and will throw events as well.
As PhaDaPhunk explained, Space is a MouseClick
for any component that accepts a MouseClick, but I haven't found a detailed explanation for it. I'd assume it's the default behavior of all controls. The Microsoft guide to accessibility seems to imply that is so in their section on keyboard-based navigation
Incidentally, this Microsoft support knowledge base entry seems to show that the spacebar implementation went from Button.Click to Button.MouseClick. Perhaps that's the reason for it's different behavior.