Skip to content

Commit

Permalink
refactored the handling of a keyboard event
Browse files Browse the repository at this point in the history
  • Loading branch information
psygo committed Sep 26, 2020
1 parent 11799e7 commit 5f6951a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/src/kbd.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ class Kbd {
// completely loaded at first, but only when everything has been completely
// loaded (`onLoad`).
window.addEventListener('yt-navigate-start', (_) => _completeReset());
document.body.onKeyDown.listen((KeyboardEvent keyboardEvent) {
_keyboardEvent = keyboardEvent;
_deactivateFilterButtonIfSearchPage();
if (_noInputFocus) _keySwitch();
});
document.body.onKeyDown.listen(_handleKeyboardEvent);
}

void _handleKeyboardEvent(KeyboardEvent keyboardEvent) {
_keyboardEvent = keyboardEvent;
_deactivateFilterButtonIfSearchPage();
if (_noInputFocus) _keySwitch();
}

void _completeReset() {
Expand Down

0 comments on commit 5f6951a

Please sign in to comment.