Skip to content

Commit

Permalink
rustdoc: Bind keydown instead of keypress for nav
Browse files Browse the repository at this point in the history
Apparently keypress doesn't quite work in all browsers due to some not invoking
the handler and jquery not setting the right `which` field in all circumstances.
According to http://stackoverflow.com/questions/2166771 switching over to
`keydown` works and it appears to do the trick. Tested in Safari, Firefox, and
Chrome.

Closes #15011
  • Loading branch information
alexcrichton committed Jul 25, 2014
1 parent 724bcec commit 80efb22
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@
}, 20);
});

$(document).off('keypress.searchnav');
$(document).on('keypress.searchnav', function(e) {
$(document).off('keydown.searchnav');
$(document).on('keydown.searchnav', function(e) {
var $active = $results.filter('.highlighted');

if (e.which === 38) { // up
Expand Down

0 comments on commit 80efb22

Please sign in to comment.