aboutsummaryrefslogtreecommitdiff
path: root/src/shared/settings/KeySequence.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/settings/KeySequence.ts')
-rw-r--r--src/shared/settings/KeySequence.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/shared/settings/KeySequence.ts b/src/shared/settings/KeySequence.ts
index abae61a..de1c6bb 100644
--- a/src/shared/settings/KeySequence.ts
+++ b/src/shared/settings/KeySequence.ts
@@ -26,6 +26,21 @@ export default class KeySequence {
return true;
}
+ isDigitOnly(): boolean {
+ return this.keys.every(key => key.isDigit());
+ }
+
+ splitNumericPrefix(): [KeySequence, KeySequence] {
+ let nonDigitIndex = this.keys.findIndex(key => !key.isDigit());
+ if (nonDigitIndex === -1) {
+ return [this, new KeySequence([])];
+ }
+ return [
+ new KeySequence(this.keys.slice(0, nonDigitIndex)),
+ new KeySequence(this.keys.slice(nonDigitIndex)),
+ ];
+ }
+
static fromMapKeys(keys: string): KeySequence {
const fromMapKeysRecursive = (
remaining: string, mappedKeys: Key[],