Browse Source

LibGUI: Add GUI::KeyEvent::is_arrow_key()

Andreas Kling 3 năm trước cách đây
mục cha
commit
0d8373287c
1 tập tin đã thay đổi với 13 bổ sung0 xóa
  1. 13 0
      Userland/Libraries/LibGUI/Event.h

+ 13 - 0
Userland/Libraries/LibGUI/Event.h

@@ -346,6 +346,19 @@ public:
 
     String to_string() const;
 
+    bool is_arrow_key() const
+    {
+        switch (m_key) {
+        case KeyCode::Key_Up:
+        case KeyCode::Key_Down:
+        case KeyCode::Key_Left:
+        case KeyCode::Key_Right:
+            return true;
+        default:
+            return false;
+        }
+    }
+
 private:
     friend class WindowServerConnection;
     KeyCode m_key { KeyCode::Key_Invalid };