Skip to content

Commit 898eefc

Browse files
committed
prevent alt default action when alt is bound in any keybinding
fixes #2180
1 parent 22bf138 commit 898eefc

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/renderer/src/App.tsx

+12-4
Original file line numberDiff line numberDiff line change
@@ -2316,17 +2316,25 @@ function App() {
23162316
runStartupCheck({ customFfPath });
23172317
}, [customFfPath]);
23182318

2319+
const haveBoundAlt = useMemo(() => keyBindings.some(({ keys }) => keys.split('+').includes('alt')), [keyBindings]);
2320+
23192321
useEffect(() => {
2320-
const keyScrollPreventer = (e: KeyboardEvent) => {
2322+
const handleKeydown = (e: KeyboardEvent) => {
2323+
// Keyboard scroll prevention:
23212324
// https://stackoverflow.com/questions/8916620/disable-arrow-key-scrolling-in-users-browser
23222325
if (e.target === document.body && [32, 37, 38, 39, 40].includes(e.keyCode)) {
23232326
e.preventDefault();
23242327
}
2328+
2329+
// if the user has bound alt in any of their keybindings, prevent alt from triggering the menu https://github.com/mifi/lossless-cut/issues/2180
2330+
if (haveBoundAlt && e.code === 'AltLeft') {
2331+
e.preventDefault();
2332+
}
23252333
};
23262334

2327-
window.addEventListener('keydown', keyScrollPreventer);
2328-
return () => window.removeEventListener('keydown', keyScrollPreventer);
2329-
}, []);
2335+
window.addEventListener('keydown', handleKeydown);
2336+
return () => window.removeEventListener('keydown', handleKeydown);
2337+
}, [haveBoundAlt]);
23302338

23312339
const showLeftBar = batchFiles.length > 0;
23322340

0 commit comments

Comments
 (0)