diff --git a/4chan_x.user.js b/4chan_x.user.js index c76c20f0b..43af32fa8 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -724,19 +724,19 @@ }, cb: { keydown: function(e) { - var o, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2, _ref3; + var k, o, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2, _ref3; if (((_ref = e.target.nodeName) === 'TEXTAREA' || _ref === 'INPUT') && !e.altKey && !e.ctrlKey && !(e.keyCode === 27)) { return; } - key = keybinds.cb.keyCode(e); + k = keybinds.cb.keyCode(e); if (e.altKey) { - key = 'alt+' + key; + k = 'alt+' + k; } if (e.ctrlKey) { - key = 'ctrl+' + key; + k = 'ctrl+' + k; } thread = nav.getThread(); - switch (key) { + switch (k) { case conf.close: if (o = $('#overlay')) { $.rm(o); @@ -827,21 +827,21 @@ return e.preventDefault(); }, keyCode: function(e, options) { - var kc; + var k, kc; kc = e.keyCode; if ((65 <= kc && kc <= 90)) { - key = String.fromCharCode(kc); + k = String.fromCharCode(kc); if (!e.shiftKey) { - key = key.toLowerCase(); + k = k.toLowerCase(); } } else if ((48 <= kc && kc <= 57)) { - key = String.fromCharCode(kc); + k = String.fromCharCode(kc); } else if (kc === 27) { - key = 'Esc'; + k = 'Esc'; } else if (options && kc === 8) { - key = ''; + k = ''; } - return key; + return k; } }, img: function(thread, all) { @@ -1115,21 +1115,22 @@ return g.hiddenReplies = {}; }, keybind: function(e) { + var k; e.preventDefault(); e.stopPropagation(); - key = keybinds.cb.keyCode(e, true); - if (key != null) { - if (key) { + k = keybinds.cb.keyCode(e, true); + if (k != null) { + if (k) { if (e.altKey) { - key = 'alt+' + key; + k = 'alt+' + k; } if (e.ctrlKey) { - key = 'ctrl+' + key; + k = 'ctrl+' + k; } } - this.value = key; - $.setValue(this.name, key); - return conf[this.name] = key; + this.value = k; + $.setValue(this.name, k); + return conf[this.name] = k; } }, time: function(e) { diff --git a/changelog b/changelog index e2c38d237..ce4752751 100644 --- a/changelog +++ b/changelog @@ -2,6 +2,7 @@ github - mayhem: - Make updater's settings dynamic - fix remember updater's interval settings + - fix wrong keybind input in options 2.16.1 - mayhem: diff --git a/script.coffee b/script.coffee index 03c5fb09e..00409c999 100644 --- a/script.coffee +++ b/script.coffee @@ -519,12 +519,12 @@ keybinds = cb: keydown: (e) -> return if e.target.nodeName in ['TEXTAREA', 'INPUT'] and not e.altKey and not e.ctrlKey and not (e.keyCode is 27) - key = keybinds.cb.keyCode e - if e.altKey then key = 'alt+' + key - if e.ctrlKey then key = 'ctrl+' + key + k = keybinds.cb.keyCode e + if e.altKey then k = 'alt+' + k + if e.ctrlKey then k = 'ctrl+' + k thread = nav.getThread() - switch key + switch k when conf.close if o = $ '#overlay' $.rm o @@ -591,16 +591,16 @@ keybinds = keyCode: (e, options) -> kc = e.keyCode if 65 <= kc <= 90 #A-Z - key = String.fromCharCode kc + k = String.fromCharCode kc if !e.shiftKey - key = key.toLowerCase() + k = k.toLowerCase() else if 48 <= kc <= 57 #0-9 - key = String.fromCharCode kc + k = String.fromCharCode kc else if kc is 27 - key = 'Esc' + k = 'Esc' else if options and kc is 8 - key = '' - key + k = '' + k img: (thread, all) -> if all @@ -884,15 +884,15 @@ options = keybind: (e) -> e.preventDefault() e.stopPropagation() - key = keybinds.cb.keyCode e, true + k = keybinds.cb.keyCode e, true - if key? - if key - key = 'alt+' + key if e.altKey - key = 'ctrl+' + key if e.ctrlKey - @value = key - $.setValue @name, key - conf[@name] = key + if k? + if k + k = 'alt+' + k if e.altKey + k = 'ctrl+' + k if e.ctrlKey + @value = k + $.setValue @name, k + conf[@name] = k time: (e) -> $.setValue 'time', @value Time.foo()