diff --git a/js/app.js b/js/app.js index 25191b0..04d2795 100644 --- a/js/app.js +++ b/js/app.js @@ -7812,6 +7812,21 @@ async function init() { // the user staring at "Press combo…". function onKeyUp(e) { if (!heldMods) return; + // Windows consumes the KEYDOWN of a combo it routed elsewhere, + // but the KEYUP of the final key often still reaches us. When it + // does we can name the exact combo the user tried; otherwise we + // fall back to the modifiers below. This can only fire on a + // swallowed key — an accepted combo ends the capture on keydown. + const k = e.key || ''; + const isMod = /^(Control|Shift|Alt|Meta|OS)$/.test(k); + if (!isMod && + ((k.length === 1 && /[a-z0-9]/i.test(k)) || /^F([1-9]|1[0-2])$/i.test(k))) { + const combo = heldMods + '+' + k.toUpperCase(); + finish(true); + toast(combo + ' is already used by another app — the keystroke ' + + 'never reaches us. Pick a different combo.', 'warning'); + return; + } if (e.ctrlKey || e.shiftKey || e.altKey || e.metaKey) return; const mods = heldMods; finish(true);