}
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// from your event handler you can: return stop_event(e)
function stop_event(e) {
// try {
// return false; // IE-compat
// }
}
-document.addEventListener(
- 'keydown',
- function(e) {
- // [de]activate on ^C
- // deactivate on ESC
- if(
- (e.ctrlKey && e.keyCode == 67)
- || (e.keyCode == 27 && active == 1)
- ) {
- if(active) {
- got = '';
- removeAllHints();
- } else {
- followLinks(got);
- }
- active = 1 - active;
- return stop_event(e);
- } else {
- if(active == 1 && !e.ctrlKey && !e.shiftKey && !e.altKey) {
- if(key_to_char[e.keyCode]) {
- got += key_to_char[e.keyCode];
+
+function init() {
+ document.addEventListener(
+ 'keydown',
+ function(e) {
+ // [de]activate on ^C
+ // deactivate on ESC
+ if(
+ (e.ctrlKey && e.keyCode == 67)
+ || (e.keyCode == 27 && active == 1)
+ ) {
+ if(active) {
+ got = '';
+ removeAllHints();
+ } else {
followLinks(got);
- return stop_event(e);
+ }
+ active = 1 - active;
+ return stop_event(e);
+ } else {
+ if(active == 1 && !e.ctrlKey && !e.shiftKey && !e.altKey) {
+ if(key_to_char[e.keyCode]) {
+ got += key_to_char[e.keyCode];
+ followLinks(got);
+ return stop_event(e);
+ }
+ } else {
+ // general keybinding, unrelated to numbered links
+ if (document.activeElement == document.body) { // FIXME get more specific
+ var c = key_to_char[e.keyCode];
+ switch (c) {
+ case 'c':
+ window.scrollBy(0, -200);
+ break;
+ case 't':
+ window.scrollBy(0, 200);
+ break;
+ }
+ }
}
}
- }
- },
- true);
+ },
+ true);
+}
+
+init();
+
})();