Skip to content

Commit

Permalink
[x/tour] tour: fix pageup/pagedown navigation on non-chrome browsers
Browse files Browse the repository at this point in the history
FF and IE fail to populate event.keyCode, but instead populate
event.which with the key code. event.key is a DOMString of "PageUp"
or "PageDown" in this case, so remove the invalid comparision to a
numeric key code and instead compare the keycode to event.which.

Fixes golang/go#8829

Change-Id: I7192d2e561e2be5472018d8a3b06a91ab9dab49b
Reviewed-on: https://go-review.googlesource.com/15001
Reviewed-by: Andrew Gerrand <adg@golang.org>
X-Tour-Commit: aef6c802ede697bfc71a740ccd720cc12c6de29b
  • Loading branch information
andrewaustin authored and adg committed Sep 25, 2015
1 parent 54906d0 commit a00061e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tour/static/js/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ directive('onpageup', function() {
return function(scope, elm, attrs) {
elm.attr('tabindex', 0);
elm.keyup(function(evt) {
var key = evt.key || evt.keyCode;
var key = evt.which || evt.keyCode;
if (key == 33 && !evt.ctrlKey) {
scope.$apply(attrs.onpageup);
evt.preventDefault();
Expand All @@ -27,7 +27,7 @@ directive('onpagedown', function() {
return function(scope, elm, attrs) {
elm.attr('tabindex', 0);
elm.keyup(function(evt) {
var key = evt.key || evt.keyCode;
var key = evt.which || evt.keyCode;
if (key == 34 && !evt.ctrlKey) {
scope.$apply(attrs.onpagedown);
evt.preventDefault();
Expand Down

0 comments on commit a00061e

Please sign in to comment.