From 6db787bb05637031626de6477c8f543f7bdcaeac Mon Sep 17 00:00:00 2001 From: Ian Sanders Date: Mon, 11 Sep 2023 18:29:28 +0000 Subject: [PATCH] Rename all references from chord to sequence --- pages/hotkey_mapper.html | 32 ++++++++++++++++---------------- src/index.ts | 12 ++++++------ src/{chord.ts => sequence.ts} | 8 ++++---- 3 files changed, 26 insertions(+), 26 deletions(-) rename src/{chord.ts => sequence.ts} (74%) diff --git a/pages/hotkey_mapper.html b/pages/hotkey_mapper.html index 34a5619..5315559 100644 --- a/pages/hotkey_mapper.html +++ b/pages/hotkey_mapper.html @@ -20,7 +20,7 @@

Hotkey Code

aria-roledescription="Input Capture" autofocus aria-labelledby="app-name" - aria-describedby="hint chord-hint" + aria-describedby="hint sequence-hint" aria-live="assertive" aria-atomic="true" id="hotkey-code" @@ -29,10 +29,10 @@

Hotkey Code

/>
- - + @@ -47,19 +47,19 @@

Hotkey Code

diff --git a/src/index.ts b/src/index.ts index 84cd191..d4fb1ff 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,13 +1,13 @@ import {Leaf, RadixTrie} from './radix-trie' import {fireDeterminedAction, expandHotkeyToEdges, isFormField} from './utils' import eventToHotkeyString from './hotkey' -import ChordTracker from './chord' +import SequenceTracker from './sequence' const hotkeyRadixTrie = new RadixTrie() const elementsLeaves = new WeakMap>>() let currentTriePosition: RadixTrie | Leaf = hotkeyRadixTrie -const chordTracker = new ChordTracker({ +const sequenceTracker = new SequenceTracker({ onReset() { currentTriePosition = hotkeyRadixTrie } @@ -26,10 +26,10 @@ function keyDownHandler(event: KeyboardEvent) { // they've pressed a wrong key-combo and we should reset the flow const newTriePosition = (currentTriePosition as RadixTrie).get(eventToHotkeyString(event)) if (!newTriePosition) { - chordTracker.reset() + sequenceTracker.reset() return } - chordTracker.registerKeypress(eventToHotkeyString(event)) + sequenceTracker.registerKeypress(eventToHotkeyString(event)) currentTriePosition = newTriePosition if (newTriePosition instanceof Leaf) { @@ -48,11 +48,11 @@ function keyDownHandler(event: KeyboardEvent) { } if (elementToFire && shouldFire) { - fireDeterminedAction(elementToFire, chordTracker.path) + fireDeterminedAction(elementToFire, sequenceTracker.path) event.preventDefault() } - chordTracker.reset() + sequenceTracker.reset() } } diff --git a/src/chord.ts b/src/sequence.ts similarity index 74% rename from src/chord.ts rename to src/sequence.ts index 012cc31..a40d133 100644 --- a/src/chord.ts +++ b/src/sequence.ts @@ -1,15 +1,15 @@ -interface ChordTrackerOptions { +interface SequenceTrackerOptions { onReset?: () => void } -export default class ChordTracker { +export default class SequenceTracker { static readonly CHORD_TIMEOUT = 1500 private _path: readonly string[] = [] private timer: number | null = null private onReset - constructor({onReset}: ChordTrackerOptions = {}) { + constructor({onReset}: SequenceTrackerOptions = {}) { this.onReset = onReset } @@ -37,6 +37,6 @@ export default class ChordTracker { private startTimer(): void { this.killTimer() - this.timer = window.setTimeout(() => this.reset(), ChordTracker.CHORD_TIMEOUT) + this.timer = window.setTimeout(() => this.reset(), SequenceTracker.CHORD_TIMEOUT) } }