Permalink
Browse files

[ux] Add vim-like go to

  • Loading branch information...
1 parent 4dbaea1 commit 7cbcdce18508af3174acbfc2088fad240ec354ca @mmalecki committed Apr 3, 2012
Showing with 15 additions and 1 deletion.
  1. +15 −1 js/presents/plugins/controls.js
@@ -1,17 +1,31 @@
(function (exports) {
var Controls = exports.Controls = {};
+ var pageNumber = null;
+
Controls.attach = function (options) {
var self = this;
document.addEventListener('keypress', function (e) {
var c = String.fromCharCode(e.keyCode);
- if (c == "h" || c == "k") {
+ if (pageNumber !== null) {
+ if (c === '\r') {
+ self.goTo(+pageNumber);
+ pageNumber = null;
+ }
+ else {
+ pageNumber += c;
+ }
+ }
+ else if (c == "h" || c == "k") {
self.previous();
}
else if (c == "l" || c == "j") {
self.next();
}
+ else if (c === ':') {
+ pageNumber = '';
+ }
});
};
})(window);

0 comments on commit 7cbcdce

Please sign in to comment.