'before-input-event' is missing the code property #8471

This commit is contained in:
liusi 2017-02-02 16:23:07 +08:00
parent 91ed9aeeee
commit 87392ff046
3 changed files with 8 additions and 0 deletions

View file

@ -224,6 +224,8 @@ v8::Local<v8::Value> Converter<content::NativeWebKeyboardEvent>::ToV8(
else if (in.type == blink::WebInputEvent::Type::KeyUp) else if (in.type == blink::WebInputEvent::Type::KeyUp)
dict.Set("type", "keyUp"); dict.Set("type", "keyUp");
dict.Set("key", ui::KeycodeConverter::DomKeyToKeyString(in.domKey)); dict.Set("key", ui::KeycodeConverter::DomKeyToKeyString(in.domKey));
dict.Set("code",
ui::KeycodeConverter::DomCodeToCodeString(static_cast<ui::DomCode>(in.domCode)));
using Modifiers = blink::WebInputEvent::Modifiers; using Modifiers = blink::WebInputEvent::Modifiers;
dict.Set("isAutoRepeat", (in.modifiers & Modifiers::IsAutoRepeat) != 0); dict.Set("isAutoRepeat", (in.modifiers & Modifiers::IsAutoRepeat) != 0);

View file

@ -240,6 +240,7 @@ Returns:
* `input` Object - Input properties * `input` Object - Input properties
* `type` String - Either `keyUp` or `keyDown` * `type` String - Either `keyUp` or `keyDown`
* `key` String - Equivalent to [KeyboardEvent.key][keyboardevent] * `key` String - Equivalent to [KeyboardEvent.key][keyboardevent]
* `code` String - Equivalent to [KeyboardEvent.code][keyboardevent]
* `isAutoRepeat` Boolean - Equivalent to [KeyboardEvent.repeat][keyboardevent] * `isAutoRepeat` Boolean - Equivalent to [KeyboardEvent.repeat][keyboardevent]
* `shift` Boolean - Equivalent to [KeyboardEvent.shiftKey][keyboardevent] * `shift` Boolean - Equivalent to [KeyboardEvent.shiftKey][keyboardevent]
* `control` Boolean - Equivalent to [KeyboardEvent.controlKey][keyboardevent] * `control` Boolean - Equivalent to [KeyboardEvent.controlKey][keyboardevent]

View file

@ -121,6 +121,7 @@ describe('webContents module', function () {
w.webContents.once('before-input-event', (event, input) => { w.webContents.once('before-input-event', (event, input) => {
assert.equal(input.type, opts.type) assert.equal(input.type, opts.type)
assert.equal(input.key, opts.key) assert.equal(input.key, opts.key)
assert.equal(input.code, opts.code)
assert.equal(input.isAutoRepeat, opts.isAutoRepeat) assert.equal(input.isAutoRepeat, opts.isAutoRepeat)
assert.equal(input.shift, opts.shift) assert.equal(input.shift, opts.shift)
assert.equal(input.control, opts.control) assert.equal(input.control, opts.control)
@ -148,6 +149,7 @@ describe('webContents module', function () {
return testBeforeInput({ return testBeforeInput({
type: 'keyDown', type: 'keyDown',
key: 'A', key: 'A',
code: 'KeyA',
keyCode: 'a', keyCode: 'a',
shift: true, shift: true,
control: true, control: true,
@ -159,6 +161,7 @@ describe('webContents module', function () {
return testBeforeInput({ return testBeforeInput({
type: 'keyUp', type: 'keyUp',
key: '.', key: '.',
code: 'Period',
keyCode: '.', keyCode: '.',
shift: false, shift: false,
control: true, control: true,
@ -170,6 +173,7 @@ describe('webContents module', function () {
return testBeforeInput({ return testBeforeInput({
type: 'keyUp', type: 'keyUp',
key: '!', key: '!',
code: 'Digit1',
keyCode: '1', keyCode: '1',
shift: true, shift: true,
control: false, control: false,
@ -181,6 +185,7 @@ describe('webContents module', function () {
return testBeforeInput({ return testBeforeInput({
type: 'keyUp', type: 'keyUp',
key: 'Tab', key: 'Tab',
code: 'Tab',
keyCode: 'Tab', keyCode: 'Tab',
shift: false, shift: false,
control: true, control: true,