'before-input-event' is missing the code property #8471
authorliusi <siyuan.liu@autodesk.com>
Thu, 2 Feb 2017 08:23:07 +0000 (16:23 +0800)
committerliusi <siyuan.liu@autodesk.com>
Thu, 2 Feb 2017 08:23:07 +0000 (16:23 +0800)
atom/common/native_mate_converters/blink_converter.cc
docs/api/web-contents.md
spec/api-web-contents-spec.js

index 0021e87383801fffb7ed743769fd58ec91a12bb8..fcc4a7654ddd0aa8b24357684b552bf7d81baa6f 100644 (file)
@@ -224,6 +224,8 @@ v8::Local<v8::Value> Converter<content::NativeWebKeyboardEvent>::ToV8(
   else if (in.type == blink::WebInputEvent::Type::KeyUp)
     dict.Set("type", "keyUp");
   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;
   dict.Set("isAutoRepeat", (in.modifiers & Modifiers::IsAutoRepeat) != 0);
index 77cd2d4c6b4acdf08e9f8af9665b4469ee6c5afa..0dd56cda16f616c3c9871e2893a8be832a6c02a2 100644 (file)
@@ -240,6 +240,7 @@ Returns:
 * `input` Object - Input properties
   * `type` String - Either `keyUp` or `keyDown`
   * `key` String - Equivalent to [KeyboardEvent.key][keyboardevent]
+  * `code` String - Equivalent to [KeyboardEvent.code][keyboardevent]
   * `isAutoRepeat` Boolean - Equivalent to [KeyboardEvent.repeat][keyboardevent]
   * `shift` Boolean - Equivalent to [KeyboardEvent.shiftKey][keyboardevent]
   * `control` Boolean - Equivalent to [KeyboardEvent.controlKey][keyboardevent]
index fb9c17125aa225ff6a8a36b760d1c2ac86de63bd..a4d8a7d1e43fe5de22d66278d9e2d10c8644b09c 100644 (file)
@@ -121,6 +121,7 @@ describe('webContents module', function () {
             w.webContents.once('before-input-event', (event, input) => {
               assert.equal(input.type, opts.type)
               assert.equal(input.key, opts.key)
+              assert.equal(input.code, opts.code)
               assert.equal(input.isAutoRepeat, opts.isAutoRepeat)
               assert.equal(input.shift, opts.shift)
               assert.equal(input.control, opts.control)
@@ -148,6 +149,7 @@ describe('webContents module', function () {
           return testBeforeInput({
             type: 'keyDown',
             key: 'A',
+            code: 'KeyA',
             keyCode: 'a',
             shift: true,
             control: true,
@@ -159,6 +161,7 @@ describe('webContents module', function () {
           return testBeforeInput({
             type: 'keyUp',
             key: '.',
+            code: 'Period',
             keyCode: '.',
             shift: false,
             control: true,
@@ -170,6 +173,7 @@ describe('webContents module', function () {
           return testBeforeInput({
             type: 'keyUp',
             key: '!',
+            code: 'Digit1',
             keyCode: '1',
             shift: true,
             control: false,
@@ -181,6 +185,7 @@ describe('webContents module', function () {
           return testBeforeInput({
             type: 'keyUp',
             key: 'Tab',
+            code: 'Tab',
             keyCode: 'Tab',
             shift: false,
             control: true,