Detecting F1 hotkey pressed twice

What function should be called to check if the F1 key was pressed twice and then depressed?

How to receive a message from the system that a key has been pressed or released?