How do I make a program detect which key is pressed, and depending on the key that's pressed it would execute specific script?

For example, if you press 'h' the script 'Beep(2000,500);' would be activated - but if you press any other keys nothing would happen.

Thanks in advance.