Index: ui/views/events/event.cc |
diff --git a/ui/views/events/event.cc b/ui/views/events/event.cc |
index fa8ce364a55d3284f540eff7db373962962f20c6..a1a31554f3e1457adbf9a0fa84635cd1eca1c74c 100644 |
--- a/ui/views/events/event.cc |
+++ b/ui/views/events/event.cc |
@@ -87,6 +87,22 @@ KeyEvent::KeyEvent(ui::EventType type, |
unmodified_character_(0) { |
} |
+bool KeyEvent::IsNumPadDigit() const { |
+ if (key_code_ >= VK_NUMPAD0 && key_code_ <= VK_NUMPAD9) |
+ return true; |
+ |
+ // Check for num pad keys without NumLock. |
+ // Note: there is no easy way to know if a the key that was pressed comes from |
+ // the num pad or the rest of the keyboard. Investigating how |
+ // TranslateMessage() generates the WM_KEYCHAR from an |
+ // ALT + <NumPad sequences> it appears it looks at the extended key flag |
+ // (which is on if the key pressed comes from one of the 3 clusters to |
+ // the left of the numeric keypad). So we use it as well. |
+ return ((flags() & ui::EF_EXTENDED) == 0) && |
+ ((key_code_ >= VK_PRIOR && key_code_ <= VK_DOWN) || // All but 0 and 5. |
+ (key_code_ == VK_CLEAR) || (key_code_ == VK_INSERT)); // Keys 0 and 5. |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// MouseEvent, public: |