From 8fbb000a83e8b5bfb0c5eb4f00381ab102dbe2ec Mon Sep 17 00:00:00 2001 From: Eddie Wang Date: Wed, 22 Feb 2023 08:26:43 -0800 Subject: [PATCH 1/2] add cut and enter --- index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 1c849f3..e52a4f1 100644 --- a/index.js +++ b/index.js @@ -44,7 +44,6 @@ app.on("ready", () => { mb.on("ready", () => { const { window } = mb; - if (process.platform !== "darwin") { window.setSkipTaskbar(true); } else { @@ -138,7 +137,20 @@ app.on("ready", () => { // register cmd+c/cmd+v events contents.on("before-input-event", (event, input) => { const { control, meta, key } = input; + + if (input.type !== "keyDown" && key == "Enter") { + // if shift is also pressed, ignore + if (input.shift) return; + + console.log("enter pressed"); + // press main > form > button + contents.executeJavaScript( + `document.querySelector('main form button').click()` + ); + } + if (!control && !meta) return; + if (key === "x") contents.cut(); if (key === "c") contents.copy(); if (key === "v") contents.paste(); if (key === "a") contents.selectAll(); From 8a61b403768857cfa91ccd19e95a4fa80fcd0b42 Mon Sep 17 00:00:00 2001 From: Eddie Wang Date: Wed, 22 Feb 2023 08:29:32 -0800 Subject: [PATCH 2/2] remove console log --- index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/index.js b/index.js index e52a4f1..71b5aca 100644 --- a/index.js +++ b/index.js @@ -142,7 +142,6 @@ app.on("ready", () => { // if shift is also pressed, ignore if (input.shift) return; - console.log("enter pressed"); // press main > form > button contents.executeJavaScript( `document.querySelector('main form button').click()`