diff --git a/src/components/Hint.tsx b/src/components/Hint.tsx index bf39db46..d92fb31c 100644 --- a/src/components/Hint.tsx +++ b/src/components/Hint.tsx @@ -16,16 +16,23 @@ interface Props { const Hint = ({ regex, flags, hiddenFlags }: Props) => { const popoverButtonRef = useRef(null); + const blockHintKey = e => { + if (e.altKey && e.code === 'KeyH') { + e.preventDefault(); + } + }; + const toggleShow = e => { - e.preventDefault(); const lastActiveElement = window.document.activeElement; - if (e.altKey && e.key.toLowerCase() === 'h') { + if (e.altKey && e.code === 'KeyH') { + e.preventDefault(); popoverButtonRef.current.click(); (lastActiveElement as HTMLElement).focus(); } }; + useEventListener('keydown', blockHintKey); useEventListener('keyup', toggleShow); return ( diff --git a/src/components/Shortcut.tsx b/src/components/Shortcut.tsx index d3d1ae77..6de409f0 100644 --- a/src/components/Shortcut.tsx +++ b/src/components/Shortcut.tsx @@ -9,8 +9,14 @@ const Shortcut = ({ command }: Props) => { const altKey = isMacOS() ? '⌥' : 'Alt'; - const readableCommand = command.replace(/\+/g, ' + ').replace(/alt/g, altKey).toUpperCase(); - + const readableCommand = command + .replace(/\+/g, ' + ') + .replace(/alt/g, altKey) + .split(' ') + .map(token => + token.length === 1 && /[a-zA-Z]/.test(token) ? token.toLowerCase() : token.toUpperCase(), + ) + .join(' '); return (