From 070772b4b984e0bc03cea28388dffaa63b14d0d0 Mon Sep 17 00:00:00 2001 From: gellert Date: Sat, 6 Feb 2016 22:33:21 +0100 Subject: [PATCH] Added special key identifiers for OSX and Windows --- atom/common/keyboard_util.cc | 10 ++++++++++ docs/api/web-contents.md | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/atom/common/keyboard_util.cc b/atom/common/keyboard_util.cc index e5dedd8..1884246 100644 --- a/atom/common/keyboard_util.cc +++ b/atom/common/keyboard_util.cc @@ -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; diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index dde701d..31c5580 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -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: -- 2.7.4