mirror of
https://github.com/heyman/heynote.git
synced 2024-12-28 09:39:05 +01:00
29 lines
1.0 KiB
JavaScript
29 lines
1.0 KiB
JavaScript
import CONFIG from "./config"
|
|
import { isMac } from "./detect-platform"
|
|
|
|
|
|
export function onBeforeInputEvent({win, event, input, currentKeymap}) {
|
|
//console.log("keyboard event", input)
|
|
let metaKey = "alt"
|
|
if (isMac) {
|
|
metaKey = CONFIG.get("settings.emacsMetaKey", "meta")
|
|
}
|
|
if (currentKeymap === "emacs") {
|
|
/**
|
|
* When using Emacs keymap, we can't bind shortcuts for copy, cut and paste in the the renderer process
|
|
* using Codemirror's bind function. Therefore we have to bind them in electron land, and send
|
|
* cut, paste and copy to window.webContents
|
|
*/
|
|
if (input.code === "KeyY" && input.control) {
|
|
event.preventDefault()
|
|
win.webContents.paste()
|
|
} else if (input.code === "KeyW" && input.control) {
|
|
event.preventDefault()
|
|
win.webContents.cut()
|
|
} else if (input.code === "KeyW" && input[metaKey]) {
|
|
event.preventDefault()
|
|
win.webContents.copy()
|
|
}
|
|
}
|
|
}
|