diff options
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/Application.ts | 7 | ||||
-rw-r--r-- | src/content/controllers/KeymapController.ts | 4 | ||||
-rw-r--r-- | src/content/usecases/KeymapUseCase.ts | 4 |
3 files changed, 15 insertions, 0 deletions
diff --git a/src/content/Application.ts b/src/content/Application.ts index cfa01fd..fbfeb6d 100644 --- a/src/content/Application.ts +++ b/src/content/Application.ts @@ -40,6 +40,7 @@ export default class Application { run() { this.routeCommonComponents(); + this.routeFocusEvents(); if (window.self === window.top) { this.routeMasterComponents(); } @@ -118,4 +119,10 @@ export default class Application { this.settingController.initSettings(); } + + private routeFocusEvents() { + window.addEventListener('blur', () => { + this.keymapController.onBlurWindow(); + }); + } } diff --git a/src/content/controllers/KeymapController.ts b/src/content/controllers/KeymapController.ts index f9c2545..639b4a1 100644 --- a/src/content/controllers/KeymapController.ts +++ b/src/content/controllers/KeymapController.ts @@ -99,4 +99,8 @@ export default class KeymapController { } return true; } + + onBlurWindow() { + this.keymapUseCase.cancel(); + } } diff --git a/src/content/usecases/KeymapUseCase.ts b/src/content/usecases/KeymapUseCase.ts index 7aa7e92..e02bc48 100644 --- a/src/content/usecases/KeymapUseCase.ts +++ b/src/content/usecases/KeymapUseCase.ts @@ -70,6 +70,10 @@ export default class KeymapUseCase { return null; } + cancel() { + this.repository.clear(); + } + private keymapEntityMap(): [KeySequence, operations.Operation][] { const keymaps = this.settingRepository.get().keymaps.combine(reservedKeymaps); let entries = keymaps.entries().map( |