Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
Firefox doesn't support event.keyCode
Browse files Browse the repository at this point in the history
  • Loading branch information
georgebrock committed Dec 17, 2012
1 parent b07cb7a commit d5d5aae
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions js/base.js
Expand Up @@ -45,19 +45,21 @@


// Use keyup for special characters like escape // Use keyup for special characters like escape
$(window).keyup(function (e) { $(window).keyup(function (e) {
var code = e.charCode || e.keyCode;
if ( if (
e.keyCode === Vimulator.Utils.Keys.BACKSPACE.charCodeAt(0) || code === Vimulator.Utils.Keys.BACKSPACE.charCodeAt(0) ||
e.keyCode === Vimulator.Utils.Keys.ESC.charCodeAt(0) code === Vimulator.Utils.Keys.ESC.charCodeAt(0)
) { ) {
vim.keyPress(e.keyCode); vim.keyPress(code);
return false; return false;
} }
}); });


// Use keypress for general characters // Use keypress for general characters
$(window).keypress(function (e) { $(window).keypress(function (e) {
if (e.keyCode >= 32) { var code = e.charCode || e.keyCode;
vim.keyPress(e.keyCode); if (code >= 32) {
vim.keyPress(code);
return false; return false;
} }
}); });
Expand Down

0 comments on commit d5d5aae

Please sign in to comment.