Added special key identifiers for OSX and Windows
authorgellert <gellihegyi@gmail.com>
Sat, 6 Feb 2016 21:33:21 +0000 (22:33 +0100)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 26 Feb 2016 12:22:46 +0000 (20:22 +0800)
atom/common/keyboard_util.cc
docs/api/web-contents.md

index e5dedd8..1884246 100644 (file)
@@ -80,6 +80,16 @@ ui::KeyboardCode KeyboardCodeFromKeyIdentifier(const std::string& chr) {
   if (chr == "tab")          return ui::VKEY_TAB;
   if (chr == "escape")       return ui::VKEY_ESCAPE;
   if (chr == "control")      return ui::VKEY_CONTROL;
+#if defined(OS_MACOSX)
+  if (chr == "command"
+    || chr == "cmd"
+    || chr == "meta")        return ui::VKEY_COMMAND;
+  if (chr == "option")       return ui::VKEY_MENU;
+#endif
+#if defined(OS_WIN)
+  if (chr == "meta")         return ui::VKEY_LWIN;
+  if (chr == "altgr")        return ui::VKEY_ALTGR;
+#endif
   if (chr == "alt")          return ui::VKEY_MENU;
   if (chr == "shift")        return ui::VKEY_SHIFT;
   if (chr == "end")          return ui::VKEY_END;
index dde701d..31c5580 100644 (file)
@@ -769,8 +769,10 @@ For keyboard events, the `event` object also have following properties:
 * `keyCode` Char or String (**required**) - The character that will be sent
   as the keyboard event. Can be a single UTF-8 character, or the name of the
   key that generates the event. Accepted key names are `enter`, `backspace`,
-  `delete`, `tab`, `escape`, `control`, `alt`, `shift`, `end`, `home`, `insert`,
-  `left`, `up`, `right`, `down`, `pageUp`, `pageDown`, `printScreen`
+  `delete`, `tab`, `escape`, `control`, `alt`, `altgr` (Windows only), `shift`,
+  `end`, `home`, `insert`, `left`, `up`, `right`, `down`, `pageUp`, `pageDown`,
+  `printScreen`, `meta`, `cmd` (OSX only), `command` (OSX only), `option`
+  (OSX only)
 
 For mouse events, the `event` object also have following properties: