From 1697dd5f8bf2bec4560f30a794e6adefbf1e40bd Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 25 Jun 2011 01:07:39 +0200 Subject: [PATCH] Don't allow hotkeys without ctrl or alt within textareas or inputs. --- 4chan_x.user.js | 16 +++++++++------- script.coffee | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 62c901c01..f6f9e3856 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -745,7 +745,10 @@ }, cb: { keydown: function(e) { - var key, o, qr, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2; + var key, o, qr, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2, _ref3; + if (((_ref = d.activeElement.nodeName) === 'TEXTAREA' || _ref === 'INPUT') && !e.altKey && !e.ctrlKey) { + return; + } key = keybinds.cb.keyCode(e); if (e.altKey) { key = 'alt+' + key; @@ -753,9 +756,8 @@ if (e.ctrlKey) { key = 'ctrl+' + key; } - keybinds.key = key; thread = nav.getThread(); - switch (keybinds.key) { + switch (key) { case keybinds.close: if (o = $('#overlay')) { $.rm(o); @@ -824,13 +826,13 @@ threadHiding.toggle(thread); break; case keybinds.nextPage: - if ((_ref = $('input[value=Next]')) != null) { - _ref.click(); + if ((_ref2 = $('input[value=Next]')) != null) { + _ref2.click(); } break; case keybinds.previousPage: - if ((_ref2 = $('input[value=Previous]')) != null) { - _ref2.click(); + if ((_ref3 = $('input[value=Previous]')) != null) { + _ref3.click(); } break; case keybinds.submit: diff --git a/script.coffee b/script.coffee index f9a84fb42..3b197a1bd 100644 --- a/script.coffee +++ b/script.coffee @@ -539,13 +539,13 @@ keybinds = cb: keydown: (e) -> + return if d.activeElement.nodeName in ['TEXTAREA', 'INPUT'] and not e.altKey and not e.ctrlKey key = keybinds.cb.keyCode e if e.altKey then key = 'alt+' + key if e.ctrlKey then key = 'ctrl+' + key - keybinds.key = key thread = nav.getThread() - switch keybinds.key + switch key when keybinds.close if o = $ '#overlay' $.rm o