fix: listen to keyup instead of keypress for search field activation

The `/` character is entered into the search field after activating it via
the `keypress` event. That's unexpected behaviour.

This commit fixes that by attaching the keyboard event handler to the
`keyup` event.
This commit is contained in:
Marcus Jaschen 2016-12-15 09:38:15 +01:00
parent df84584423
commit 97cdc67c1a
2 changed files with 32 additions and 8 deletions

View File

@ -713,10 +713,6 @@ Miniflux.Event = (function() {
case 63:
Miniflux.Nav.ShowHelp();
break;
case '/':
case 47:
Miniflux.Nav.ShowSearch();
break;
case 'Q':
case 81: // Q
case 'q':
@ -752,6 +748,22 @@ Miniflux.Event = (function() {
break;
}
};
document.onkeyup = function(e) {
if (isEventIgnored(e)) {
return;
}
Miniflux.Event.lastEventType = "keyboard";
switch (e.key || e.which) {
case '/':
case 47:
Miniflux.Nav.ShowSearch();
break;
}
};
},
ListenVisibilityEvents: function() {
document.addEventListener('visibilitychange', function() {

View File

@ -196,10 +196,6 @@ Miniflux.Event = (function() {
case 63:
Miniflux.Nav.ShowHelp();
break;
case '/':
case 47:
Miniflux.Nav.ShowSearch();
break;
case 'Q':
case 81: // Q
case 'q':
@ -235,6 +231,22 @@ Miniflux.Event = (function() {
break;
}
};
document.onkeyup = function(e) {
if (isEventIgnored(e)) {
return;
}
Miniflux.Event.lastEventType = "keyboard";
switch (e.key || e.which) {
case '/':
case 47:
Miniflux.Nav.ShowSearch();
break;
}
};
},
ListenVisibilityEvents: function() {
document.addEventListener('visibilitychange', function() {