Merge pull request #523 from aeosynth/key
slight refactor of keybinds; meta
This commit is contained in:
commit
55a036708e
@ -1054,10 +1054,16 @@
|
|||||||
return $.on(d, 'keydown', Keybinds.keydown);
|
return $.on(d, 'keydown', Keybinds.keydown);
|
||||||
},
|
},
|
||||||
keydown: function(e) {
|
keydown: function(e) {
|
||||||
var key, link, o, ta, thread;
|
var key, link, o, target, thread;
|
||||||
if (!(key = Keybinds.keyCode(e)) || /TEXTAREA|INPUT/.test(e.target.nodeName) && !(e.altKey || e.ctrlKey || e.keyCode === 27)) {
|
if (!(key = Keybinds.keyCode(e))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
target = e.target;
|
||||||
|
if (/TEXTAREA|INPUT/.test(target.nodeName)) {
|
||||||
|
if (!((key === 'Esc') || (/\+/.test(key)))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
thread = Nav.getThread();
|
thread = Nav.getThread();
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case Conf.openQR:
|
case Conf.openQR:
|
||||||
@ -1084,15 +1090,13 @@
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Conf.spoiler:
|
case Conf.spoiler:
|
||||||
ta = e.target;
|
if (target.nodeName !== 'TEXTAREA') {
|
||||||
if (ta.nodeName !== 'TEXTAREA') {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Keybinds.tags('spoiler', ta);
|
Keybinds.tags('spoiler', ta);
|
||||||
break;
|
break;
|
||||||
case Conf.code:
|
case Conf.code:
|
||||||
ta = e.target;
|
if (target.nodeName !== 'TEXTAREA') {
|
||||||
if (ta.nodeName !== 'TEXTAREA') {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Keybinds.tags('code', ta);
|
Keybinds.tags('code', ta);
|
||||||
@ -1233,6 +1237,9 @@
|
|||||||
if (e.ctrlKey) {
|
if (e.ctrlKey) {
|
||||||
key = 'ctrl+' + key;
|
key = 'ctrl+' + key;
|
||||||
}
|
}
|
||||||
|
if (e.metaKey) {
|
||||||
|
key = 'meta+' + key;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return key;
|
return key;
|
||||||
},
|
},
|
||||||
@ -2280,7 +2287,7 @@
|
|||||||
<input type=radio name=tab hidden id=keybinds_tab>\
|
<input type=radio name=tab hidden id=keybinds_tab>\
|
||||||
<div>\
|
<div>\
|
||||||
<div class=warning><code>Keybinds</code> are disabled.</div>\
|
<div class=warning><code>Keybinds</code> are disabled.</div>\
|
||||||
<div>Allowed keys: Ctrl, Alt, a-z, A-Z, 0-9, Up, Down, Right, Left.</div>\
|
<div>Allowed keys: Ctrl, Alt, Meta, a-z, A-Z, 0-9, Up, Down, Right, Left.</div>\
|
||||||
<table><tbody>\
|
<table><tbody>\
|
||||||
<tr><th>Actions</th><th>Keybinds</th></tr>\
|
<tr><th>Actions</th><th>Keybinds</th></tr>\
|
||||||
</tbody></table>\
|
</tbody></table>\
|
||||||
|
|||||||
@ -793,8 +793,10 @@ Keybinds =
|
|||||||
$.on d, 'keydown', Keybinds.keydown
|
$.on d, 'keydown', Keybinds.keydown
|
||||||
|
|
||||||
keydown: (e) ->
|
keydown: (e) ->
|
||||||
if not (key = Keybinds.keyCode(e)) or /TEXTAREA|INPUT/.test(e.target.nodeName) and not (e.altKey or e.ctrlKey or e.keyCode is 27)
|
return unless key = Keybinds.keyCode e
|
||||||
return
|
{target} = e
|
||||||
|
if /TEXTAREA|INPUT/.test target.nodeName
|
||||||
|
return unless (key is 'Esc') or (/\+/.test key)
|
||||||
|
|
||||||
thread = Nav.getThread()
|
thread = Nav.getThread()
|
||||||
switch key
|
switch key
|
||||||
@ -813,12 +815,10 @@ Keybinds =
|
|||||||
when Conf.submit
|
when Conf.submit
|
||||||
QR.submit() if QR.el and !QR.status()
|
QR.submit() if QR.el and !QR.status()
|
||||||
when Conf.spoiler
|
when Conf.spoiler
|
||||||
ta = e.target
|
return if target.nodeName isnt 'TEXTAREA'
|
||||||
return if ta.nodeName isnt 'TEXTAREA'
|
|
||||||
Keybinds.tags 'spoiler', ta
|
Keybinds.tags 'spoiler', ta
|
||||||
when Conf.code
|
when Conf.code
|
||||||
ta = e.target
|
return if target.nodeName isnt 'TEXTAREA'
|
||||||
return if ta.nodeName isnt 'TEXTAREA'
|
|
||||||
Keybinds.tags 'code', ta
|
Keybinds.tags 'code', ta
|
||||||
# Thread related
|
# Thread related
|
||||||
when Conf.watch
|
when Conf.watch
|
||||||
@ -886,8 +886,9 @@ Keybinds =
|
|||||||
else
|
else
|
||||||
null
|
null
|
||||||
if key
|
if key
|
||||||
if e.altKey then key = 'alt+' + key
|
if e.altKey then key = 'alt+' + key
|
||||||
if e.ctrlKey then key = 'ctrl+' + key
|
if e.ctrlKey then key = 'ctrl+' + key
|
||||||
|
if e.metaKey then key = 'meta+' + key
|
||||||
key
|
key
|
||||||
|
|
||||||
tags: (tag, ta) ->
|
tags: (tag, ta) ->
|
||||||
@ -1760,7 +1761,7 @@ Options =
|
|||||||
<input type=radio name=tab hidden id=keybinds_tab>
|
<input type=radio name=tab hidden id=keybinds_tab>
|
||||||
<div>
|
<div>
|
||||||
<div class=warning><code>Keybinds</code> are disabled.</div>
|
<div class=warning><code>Keybinds</code> are disabled.</div>
|
||||||
<div>Allowed keys: Ctrl, Alt, a-z, A-Z, 0-9, Up, Down, Right, Left.</div>
|
<div>Allowed keys: Ctrl, Alt, Meta, a-z, A-Z, 0-9, Up, Down, Right, Left.</div>
|
||||||
<table><tbody>
|
<table><tbody>
|
||||||
<tr><th>Actions</th><th>Keybinds</th></tr>
|
<tr><th>Actions</th><th>Keybinds</th></tr>
|
||||||
</tbody></table>
|
</tbody></table>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user