From 1a0e537d798fc4403914053051206919171db54e Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 24 Jun 2011 03:27:33 +0200 Subject: [PATCH] More combination possibilities. --- 4chan_x.user.js | 59 ++++++++++++++++++++++++------------------------- script.coffee | 40 ++++++++++++++++----------------- 2 files changed, 49 insertions(+), 50 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 4c4b2bf70..992f90cb9 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -722,18 +722,16 @@ if (!e.shiftKey) { key = key.toLowerCase(); } - if (e.ctrlKey) { - key = 'ctrl+' + key; - } - if (e.altKey) { - key = 'alt+' + key; - } - } else { - if (kc === 27) { - key = 'Esc'; - } else if ((48 <= kc && kc <= 57)) { - key = String.fromCharCode(kc); - } + } else if ((48 <= kc && kc <= 57)) { + key = String.fromCharCode(kc); + } else if (kc === 27) { + key = 'Esc'; + } + if (e.altKey) { + key = 'alt+' + key; + } + if (e.ctrlKey) { + key = 'ctrl+' + key; } keybinds.key = key; thread = nav.getThread(); @@ -1089,31 +1087,32 @@ keybind: function(e) { var kc, key; e.preventDefault(); + e.stopPropagation(); kc = e.keyCode; if ((65 <= kc && kc <= 90)) { key = String.fromCharCode(kc); if (!e.shiftKey) { key = key.toLowerCase(); } - if (e.ctrlKey) { - key = 'ctrl+' + key; - } - if (e.altKey) { - key = 'alt+' + key; - } - } else { - if (kc === 27) { - key = 'Esc'; - } else if ((48 <= kc && kc <= 57)) { - key = String.fromCharCode(kc); - } else if (kc === 8) { - key = ''; - } else { - key = this.value; - } + } else if ((48 <= kc && kc <= 57)) { + key = String.fromCharCode(kc); + } else if (kc === 27) { + key = 'Esc'; + } else if (kc === 8) { + key = ''; + } + if (key.length >= 0) { + if (key) { + if (e.altKey) { + key = 'alt+' + key; + } + if (e.ctrlKey) { + key = 'ctrl+' + key; + } + } + this.value = key; + return $.setValue("key/" + this.name, key); } - this.value = key; - return $.setValue("key/" + this.name, key); }, time: function(e) { $.setValue('time', this.value); diff --git a/script.coffee b/script.coffee index 15753b7de..be73641aa 100644 --- a/script.coffee +++ b/script.coffee @@ -517,13 +517,12 @@ keybinds = key = String.fromCharCode kc if !e.shiftKey key = key.toLowerCase() - if e.ctrlKey then key = 'ctrl+' + key - if e.altKey then key = 'alt+' + key - else - if kc is 27 - key = 'Esc' - else if 48 <= kc <= 57 #0-9 - key = String.fromCharCode kc + else if 48 <= kc <= 57 #0-9 + key = String.fromCharCode kc + else if kc is 27 + key = 'Esc' + if e.altKey then key = 'alt+' + key + if e.ctrlKey then key = 'ctrl+' + key keybinds.key = key thread = nav.getThread() @@ -867,24 +866,25 @@ options = g.hiddenReplies = {} keybind: (e) -> e.preventDefault() + e.stopPropagation() kc = e.keyCode if 65 <= kc <= 90 #A-Z key = String.fromCharCode kc if !e.shiftKey key = key.toLowerCase() - if e.ctrlKey then key = 'ctrl+' + key - if e.altKey then key = 'alt+' + key - else - if kc is 27 - key = 'Esc' - else if 48 <= kc <= 57 #0-9 - key = String.fromCharCode kc - else if kc is 8 - key = '' - else - key = @value - @value = key - $.setValue "key/#{@name}", key + else if 48 <= kc <= 57 #0-9 + key = String.fromCharCode kc + else if kc is 27 + key = 'Esc' + else if kc is 8 + key = '' + + if key.length >= 0 + if key + key = 'alt+' + key if e.altKey + key = 'ctrl+' + key if e.ctrlKey + @value = key + $.setValue "key/#{@name}", key time: (e) -> $.setValue 'time', @value Time.foo()