Merging keyCode and keyIdentifier and adjusting the docs accordingly
This commit is contained in:
parent
5fff06d2c2
commit
14740eeb8a
4 changed files with 8 additions and 10 deletions
|
@ -73,7 +73,7 @@ ui::KeyboardCode KeyboardCodeFromCharCode(base::char16 c, bool* shifted) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return key code of the char.
|
// Return key code of the char.
|
||||||
ui::KeyboardCode KeyboardCodeFromKeyIdentifier(std::string chr) {
|
ui::KeyboardCode KeyboardCodeFromKeyIdentifier(const std::string& chr) {
|
||||||
if (chr == "enter") return ui::VKEY_RETURN;
|
if (chr == "enter") return ui::VKEY_RETURN;
|
||||||
if (chr == "backspace") return ui::VKEY_BACK;
|
if (chr == "backspace") return ui::VKEY_BACK;
|
||||||
if (chr == "delete") return ui::VKEY_DELETE;
|
if (chr == "delete") return ui::VKEY_DELETE;
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace atom {
|
||||||
ui::KeyboardCode KeyboardCodeFromCharCode(base::char16 c, bool* shifted);
|
ui::KeyboardCode KeyboardCodeFromCharCode(base::char16 c, bool* shifted);
|
||||||
|
|
||||||
// Return key code of the char from a string representation of the char
|
// Return key code of the char from a string representation of the char
|
||||||
ui::KeyboardCode KeyboardCodeFromKeyIdentifier(std::string chr);
|
ui::KeyboardCode KeyboardCodeFromKeyIdentifier(const std::string& chr);
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ bool Converter<blink::WebKeyboardEvent>::FromV8(
|
||||||
|
|
||||||
if (dict.Get("keyCode", &code))
|
if (dict.Get("keyCode", &code))
|
||||||
out->windowsKeyCode = atom::KeyboardCodeFromCharCode(code, &shifted);
|
out->windowsKeyCode = atom::KeyboardCodeFromCharCode(code, &shifted);
|
||||||
else if (dict.Get("keyIdentifier", &identifier))
|
else if (dict.Get("keyCode", &identifier))
|
||||||
out->windowsKeyCode = atom::KeyboardCodeFromKeyIdentifier(
|
out->windowsKeyCode = atom::KeyboardCodeFromKeyIdentifier(
|
||||||
base::StringToLowerASCII(identifier));
|
base::StringToLowerASCII(identifier));
|
||||||
else
|
else
|
||||||
|
|
|
@ -593,14 +593,12 @@ Disable device emulation enabled by `webContents.enableDeviceEmulation`.
|
||||||
Sends an input `event` to the page.
|
Sends an input `event` to the page.
|
||||||
|
|
||||||
For keyboard events, the `event` object also have following properties:
|
For keyboard events, the `event` object also have following properties:
|
||||||
(only one of `keyCode` and `keyIdentifier` is required)
|
|
||||||
|
|
||||||
* `keyCode` Char (**required**) - A single character that will be sent as
|
* `keyCode` Char or String (**required**) - The character that will be sent
|
||||||
keyboard event. Can be any UTF-8 character.
|
as the keyboard event. Can be a single UTF-8 character, or the name of the
|
||||||
* `keyIdentifier` String (**required**) - A text representation of the character
|
key that generates the event. Accepted key names are `enter`, `backspace`,
|
||||||
that will be sent as keyboard event, can be `Enter`, `Backspace`, `Delete`,
|
`delete`, `tab`, `escape`, `control`, `alt`, `shift`, `end`, `home`, `insert`,
|
||||||
`Tab`, `Escape`, `Control`, `Alt`, `Shift`, `End`, `Home`, `Insert`, `Left`,
|
`left`, `up`, `right`, `down`, `pageUp`, `pageDown`, `printScreen`
|
||||||
`Up`, `Right`, `Down`, `PageUp`, `PageDown`, `PrintScreen`
|
|
||||||
|
|
||||||
For mouse events, the `event` object also have following properties:
|
For mouse events, the `event` object also have following properties:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue