The normal way is to overwrite
PreTranslateMessage and check for these values.
In this
webpage from Microsoft is another approach well explained and also some sample code can be found.
Tip: If you handle the keystroke make a return and not handling to the default .