You will need to add a KeyUp event handler to the form and populate the generated handler as below.
private void TestForm_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Space)
{
Close();
}
}
Please note that this only works when the focus is on the form, if any controls in the form are focused this will not work so you might have to ensure that the controls have there TabStop property to false unless you want to add KeyUp handlers for each control.