Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On my machine, every key sends a WM_KEYDOWN message except for SysReq/Print Screen key: which only seems to send WM_KEYUP.

Is this actually the case?

share|improve this question

I am getting exactly the same behaviour - I think you might need to add WM_PRINT and WM_PRINTCLIENT (Alt + Print Screen) as borderline cases.

However, why not just use DirectInput - which sits a lower level than the window manager?

share|improve this answer
direct input is deprecated, everyone tells me not to use it any more! – Cliff Harris Dec 1 '11 at 12:53
XInput then :). – Jonathan Dickinson Dec 1 '11 at 13:47
XInput only provides access to Xbox-style controllers. DirectInput, furthermore, was built on top of other APIs so is actually higher-level than just listening for WM_* messages. One could use the RawInput API in theory, but this is rarely worth it. Win32 messages are the ideal means of dealing with non-Xbox, non-joystick input devices. – Josh Petrie Dec 2 '11 at 18:07
I missed my edit window, but to clarify, DI talks to RawInput, but does so in a fashion that renders it no more efficient for practical purposes than just using the message loop you already have to have in place anyhow; I should have said this instead of the "higher level" comment. – Josh Petrie Dec 2 '11 at 18:16

Several of the old function keys such as Print Screen, Scroll Lock, etc., have peculiar behaviour because they have special hardware routines to send multiple scan codes rather than single ones, etc. This is presumably why the special messages like WM_PRINTCLIENT exist, to handle the special cases.

share|improve this answer

You can receive PrintScreen via the WM_HOTKEY message after registering it with RegisterHotKey. See this article for more information. Registering the hotkey does prevent the ordinary behavior of PrintScreen (taking a screenshot) from functioning, I believe.

But yes, you get WM_KEYUP but no WM_KEYDOWN (registering the hotkey gets you a WM_HOTKEY in place of WM_KEYDOWN). It's a bit peculiar.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.