diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js index ff21c4a69d..351e63c1f5 100644 --- a/chrome/content/zotero/integration/quickFormat.js +++ b/chrome/content/zotero/integration/quickFormat.js @@ -180,11 +180,16 @@ var Zotero_QuickFormat = new function () { // load citation data if (io.citation.citationItems.length) { // hack to get spacing right - var evt = qfiDocument.createEvent("KeyboardEvent"); - evt.initKeyEvent("keypress", true, true, qfiWindow, - 0, 0, 0, 0, - 0, " ".charCodeAt(0)); - qfe.dispatchEvent(evt); + let event = new KeyboardEvent( + "keypress", + { + key: " ", + code: "Space", + bubbles: true, + cancelable: true, + } + ); + qfe.dispatchEvent(event); await resizePromise; var node = qfe.firstChild; node.nodeValue = ""; diff --git a/test/tests/zoteroPaneTest.js b/test/tests/zoteroPaneTest.js index defb69e390..800601a8a9 100644 --- a/test/tests/zoteroPaneTest.js +++ b/test/tests/zoteroPaneTest.js @@ -465,18 +465,15 @@ describe("ZoteroPane", function() { var promise = waitForDialog(); var modifyPromise = waitForItemEvent('modify'); - var event = doc.createEvent("KeyboardEvent"); - event.initKeyEvent( + var event = new KeyboardEvent( "keypress", - true, - true, - window, - false, - false, - false, - false, - DELETE_KEY_CODE, - 0 + { + key: 'Delete', + code: 'Delete', + keyCode: DELETE_KEY_CODE, + bubbles: true, + cancelable: true + } ); tree.dispatchEvent(event); yield promise; @@ -506,18 +503,17 @@ describe("ZoteroPane", function() { var promise = waitForDialog(); var modifyPromise = waitForItemEvent('modify'); - var event = doc.createEvent("KeyboardEvent"); - event.initKeyEvent( + var event = new KeyboardEvent( "keypress", - true, - true, - window, - false, - false, - !Zotero.isMac, // shift - Zotero.isMac, // meta - DELETE_KEY_CODE, - 0 + { + key: 'Delete', + code: 'Delete', + keyCode: DELETE_KEY_CODE, + bubbles: true, + cancelable: true, + shiftKey: !Zotero.isMac, + metaKey: Zotero.isMac, + } ); tree.dispatchEvent(event); yield promise; @@ -588,9 +584,9 @@ describe("ZoteroPane", function() { { key: 'Delete', code: 'Delete', + keyCode: DELETE_KEY_CODE, metaKey: Zotero.isMac, shiftKey: !Zotero.isMac, - keyCode: DELETE_KEY_CODE, bubbles: true, cancelable: true }