While exploring electron, I have come across an issue regarding listening for the ESC
key in both the main and render processes.
In the Main process,
menu.append(new MenuItem({
label: "Hide on Escape",
visible: false,
accelerator: "Escape",
click: (item, window, event) => {
if (window.isVisible()) {
window.hide();
}
}
}))
In the Render Process,
// Key press Handler
const onKeyDownHandler = (event: React.KeyboardEvent) => {
if (isContentEditable && event.key === "Enter") {
applyContentEditable();
} else if (event.key === "Enter") {
onSelected && onSelected(pair);
} else if (event.key === "Delete") {
onDelete && onDelete(pair);
} else if (event.key === "F2") {
setIsContentEditable(true);
} else if (event.key === "Escape") {
resetContentEditable(); // Stop Renaming and get back to default
}
}
The issue arises when calling the hide function too soon before reaching the render process. How can I prevent it from hiding when triggered by the Render Process?