Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a special Mod modifier that translates to either Meta on Mac or Control on other platforms #66

Merged
merged 24 commits into from
Oct 10, 2023
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
15a2349
changes files pattern to match any test file
theinterned Dec 17, 2021
272e313
introduces hotkeyCompare and normalizeHotkey
theinterned Dec 17, 2021
89b6475
cleanup
theinterned Dec 17, 2021
0daa605
formatting
theinterned Dec 20, 2021
bf39656
account for hotkey containing both Control and Meta
theinterned Dec 20, 2021
846a166
clarify var name
theinterned Dec 20, 2021
796e5b9
rename regex vars
theinterned Dec 20, 2021
6e85b53
fix some prettier formatting and linting
theinterned Dec 20, 2021
10b7698
reverse funcitonality of normalizeHotkey
theinterned Dec 20, 2021
eb49074
remove unused hotkeyCompare()
theinterned Dec 20, 2021
d4be521
removes handling of shift key for now
theinterned Dec 30, 2021
5f69e39
normalize the hotkey stored in trie edge
theinterned Dec 30, 2021
8705871
rename hotkey-compare > normalize-hotkey
theinterned Dec 30, 2021
4ab901f
update JSDoc
theinterned Dec 31, 2021
867d12e
move export to top
theinterned Dec 31, 2021
b14ab35
normalizeHotkey sorts modifiers in consistent order
theinterned Dec 31, 2021
9bb0699
document Mod key
theinterned Dec 31, 2021
96eb941
Update README.md
theinterned Jan 4, 2022
f9dc082
Update README.md
theinterned Jan 4, 2022
2a61fcb
mention linux in mod tests
theinterned Jan 4, 2022
9171795
add test for all apple platform strings
theinterned Jan 4, 2022
730ed3e
Merge branch 'main' of https://github.com/github/hotkey into theinter…
iansan5653 Oct 9, 2023
70ca175
Update README.md
theinterned Oct 10, 2023
6693f1f
restore changes to demo.html from main
theinterned Oct 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clarify var name
  • Loading branch information
theinterned committed Dec 20, 2021
commit 846a166f5f6f1287e9c74908a81041b14b48fb1e
6 changes: 3 additions & 3 deletions src/hotkey-compare.ts
Original file line number Diff line number Diff line change
@@ -5,9 +5,9 @@ export function hotkeyCompare(hotkeyA: string, hotkeyB: string): boolean {
}

export function normalizeHotkey(hotkey: string): string {
const replaceShiftWithUpperChar = hotkey.replace(regexShiftAndChar, replaceMatchShiftAndChar)
if (regexBothModifiers.test(replaceShiftWithUpperChar)) return replaceShiftWithUpperChar
return replaceShiftWithUpperChar.replace(regexEitherModifier, 'Mod')
const hotkeyShiftReplaced = hotkey.replace(regexShiftAndChar, replaceMatchShiftAndChar)
if (regexBothModifiers.test(hotkeyShiftReplaced)) return hotkeyShiftReplaced
return hotkeyShiftReplaced.replace(regexEitherModifier, 'Mod')
}

const regexEitherModifier = /Control|Meta/