title: How to tell if shift is pressed on numpad input with NumLock on? Or at least get NumLock status?
body: <p>In Qt's keyPressEvent() and keyReleaseEvent() I'm trying to get a numpad input of key + modifier.</p>
  
  <p>Using <code>void MyWidget::keyPressEvent(QKeyEvent *evt)</code>, <code>evt-&gt;key()</code> gives the keycode (Qt::Key) and <code>evt-&gt;modifiers()</code> gives the keyboard modifiers (QFlags).</p>
  
  <ul>
  <li>For all "regular" keys I can detect all needed modifiers (shift, alt, ctrl).</li>
  <li>For numpad keys I get the correct modifiers if numLock is off.</li>
  <li>If NumLock is on, I receive ctrl and alt, but not shift.</li>
  </ul>
  
  <p>I found out that the <a href="http://blogs.msdn.com/b/oldnewthing/archive/2004/09/06/226045.aspx" rel="noreferrer">shift key overrides NumLock</a>.</p>
  
  <p>Below table shows a readout of all available Qt values about the key events.<br>
  Keystrokes to reproduce: having NumLock off, press and release num_5, then press and release shift, then press shift -> press num_5 -> release num_5 -> release shift, then toggle NumLock to on and repeat the same key presses.</p>
  
  <pre><code>table headers:
  natSC        = evt-&gt;nativeScanCode()
  natMods      = evt-&gt;nativeModifiers()
  kbdMods      = QGuiApplication::keyboardModifiers()
  queryKbdMods = QGuiApplication::queryKeyboardModifiers()
  
  NumLock |    Action     |   Event    | evt-&gt;key()  | evt-&gt;modifiers() | natSC | natMods  |   kbdMods    | queryKbdMods
  --------+---------------+------------+-------------+------------------+-------+----------+--------------+-------------
  off     | Num_5 down    | keyPress   | Key_Clear   | Keypad           |    76 |        0 | Keypad       | 0           
  off     | Num_5 up      | keyRelease | Key_Clear   | Keypad           |    76 |        0 | Keypad       | 0           
  off     | Shift down    | keyPress   | Key_Shift   | Shift            |    42 |        1 | 0            | Shift       
  off     | Shift up      | keyRelease | Key_Shift   | 0                |    42 |        0 | Shift        | 0           
  off     | Shift down    | keyPress   | Key_Shift   | Shift            |    42 |        1 | 0            | Shift       
  off     | Num_5 down    | keyPress   | Key_Clear   | Shift+Keypad     |    76 |        1 | Shift+Keypad | Shift       
  off     | Num_5 up      | keyRelease | Key_Clear   | Shift+Keypad     |    76 |        1 | Shift+Keypad | Shift       
  off     | Shift up      | keyRelease | Key_Shift   | 0                |    42 |        0 | Shift        | 0           
  --------+---------------+------------+-------------+------------------+-------+----------+--------------+-------------
  on      | NumLock dwn   | keyPress   | Key_NumLock | Keypad           |   325 | 16777728 | Keypad       | 0           
  on      | NumLock up    | keyRelease | Key_NumLock | Keypad           |   325 | 16777728 | Keypad       | 0           
  --------+---------------+------------+-------------+------------------+-------+----------+--------------+-------------
  on      | Num_5 down    | keyPress   | Key_5       | Keypad           |    76 |      512 | Keypad       | 0           
  on      | Num_5 up      | keyRelease | Key_5       | Keypad           |    76 |      512 | Keypad       | 0           
  on      | Shift down    | keyPress   | Key_Shift   | Shift            |    42 |      513 | 0            | Shift       
  on      | Shift up      | keyRelease | Key_Shift   | 0                |    42 |      512 | Shift        | 0           
  on      | Shift down    | keyPress   | Key_Shift   | Shift            |    42 |      513 | 0            | Shift       
  on      | Num_5 down    | keyRelease | Key_Shift   | 0                |    42 |      512 | Shift        | 0           
  on      | ...Num_5 down | keyPress   | Key_Clear   | Keypad           |    76 |      512 | Keypad       | 0           
  on      | Num_5 up      | keyRelease | Key_Clear   | Keypad           |    76 |      512 | Keypad       | Shift       
  on      | ...Num_5 up   | keyPress   | Key_Shift   | Shift            |    42 |      513 | 0            | Shift       
  on      | Shift up      | keyRelease | Key_Shift   | 0                |    42 |      512 | Shift        | 0           
  </code></pre>
  
  <p>You can see that shift seems to be released prior to the numpad key event.<br>
  The problem is that this "virtual" shift release event looks <em>exactly</em> the same as a regular shift release.</p>
  
  <p>My ideal solution would be to get the true shift status in keyPressEvent().<br>
  As a workaround I'd be happy to test if NumLock is enabled in keyPressEvent() - then I could give a warning if the user presses shift and ask to disable NumLock.</p>
  
  <p>I'm using Win7, but the solution should be portable, e.g. using Qt. Any ideas?</p>
  
  <p>I'd also be content with an answer "This is not possible because...".</p>