summaryrefslogtreecommitdiff
path: root/src/main.js
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2014-11-24 17:23:23 +0200
committerAlon Levy <alon@pobox.com>2014-11-24 17:23:24 +0200
commitcc211254c511b88e8171069e5c8122d53229cd51 (patch)
tree1853fa9890c8699267f67e13d48e6204d8c453fa /src/main.js
parent59101189491c041e5150b29ee2a623dfc14be102 (diff)
add alt-ctrl-o and alt-ctrl-i keyboard shortcuts
Considered using jquery.hotkeys, even tried that, but didn't actually work for me. This code seems to function under all browsers I tested (IE 11, chrome recent, FF recent - will test on IE 8).
Diffstat (limited to 'src/main.js')
-rw-r--r--src/main.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main.js b/src/main.js
index 17066ac3..f9d830e9 100644
--- a/src/main.js
+++ b/src/main.js
@@ -31,6 +31,18 @@ function(textanalysis_ui, textanalysis, buttons, history, drag_n_drop,
if (json) {
rz_core.load_from_json(json);
}
+
+ document.body.onkeyup = function(e) {
+ var key = (e.key || (e.charCode && String.charCodeAt(e.charCode))
+ || (e.which && String.charCodeAt(e.which))).toLowerCase();
+
+ if (e.altKey && e.ctrlKey && key == 'i') {
+ $('#textanalyser').focus();
+ }
+ if (e.altKey && e.ctrlKey && key == 'o') {
+ $('#search').focus();
+ }
+ };
// TODO: interaction between the hack above and this
model_core.init(rz_config);
textanalysis.init();