mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 15:05:56 +00:00
hotkey_handler: cleanup things a bit
This commit is contained in:
21
js/tt-rss.js
21
js/tt-rss.js
@@ -851,25 +851,16 @@ function hotkey_handler(e) {
|
|||||||
if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return;
|
if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return;
|
||||||
|
|
||||||
var keycode = false;
|
var keycode = false;
|
||||||
var shift_key = false;
|
|
||||||
var ctrl_key = false;
|
|
||||||
var alt_key = false;
|
|
||||||
var meta_key = false;
|
|
||||||
|
|
||||||
var cmdline = $('cmdline');
|
var cmdline = $('cmdline');
|
||||||
|
|
||||||
shift_key = e.shiftKey;
|
|
||||||
ctrl_key = e.ctrlKey;
|
|
||||||
alt_key = e.altKey;
|
|
||||||
meta_key = e.metaKey;
|
|
||||||
|
|
||||||
if (window.event) {
|
if (window.event) {
|
||||||
keycode = window.event.keyCode;
|
keycode = window.event.keyCode;
|
||||||
} else if (e) {
|
} else if (e) {
|
||||||
keycode = e.which;
|
keycode = e.which;
|
||||||
}
|
}
|
||||||
|
|
||||||
var keychar = String.fromCharCode(keycode);
|
var keychar = String.fromCharCode(keycode).toLowerCase();
|
||||||
|
|
||||||
if (keycode == 27) { // escape
|
if (keycode == 27) { // escape
|
||||||
hotkey_prefix = false;
|
hotkey_prefix = false;
|
||||||
@@ -878,8 +869,6 @@ function hotkey_handler(e) {
|
|||||||
if (keycode == 16) return; // ignore lone shift
|
if (keycode == 16) return; // ignore lone shift
|
||||||
if (keycode == 17) return; // ignore lone ctrl
|
if (keycode == 17) return; // ignore lone ctrl
|
||||||
|
|
||||||
keychar = keychar.toLowerCase();
|
|
||||||
|
|
||||||
var hotkeys = getInitParam("hotkeys");
|
var hotkeys = getInitParam("hotkeys");
|
||||||
|
|
||||||
if (!hotkey_prefix && hotkeys[0].indexOf(keychar) != -1) {
|
if (!hotkey_prefix && hotkeys[0].indexOf(keychar) != -1) {
|
||||||
@@ -904,10 +893,10 @@ function hotkey_handler(e) {
|
|||||||
var hotkey = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")";
|
var hotkey = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")";
|
||||||
|
|
||||||
// ensure ^*char notation
|
// ensure ^*char notation
|
||||||
if (shift_key) hotkey = "*" + hotkey;
|
if (e.shiftKey) hotkey = "*" + hotkey;
|
||||||
if (ctrl_key) hotkey = "^" + hotkey;
|
if (e.ctrlKey) hotkey = "^" + hotkey;
|
||||||
if (alt_key) hotkey = "+" + hotkey;
|
if (e.altKey) hotkey = "+" + hotkey;
|
||||||
if (meta_key) hotkey = "%" + hotkey;
|
if (e.metaKey) hotkey = "%" + hotkey;
|
||||||
|
|
||||||
hotkey = hotkey_prefix ? hotkey_prefix + " " + hotkey : hotkey;
|
hotkey = hotkey_prefix ? hotkey_prefix + " " + hotkey : hotkey;
|
||||||
hotkey_prefix = false;
|
hotkey_prefix = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user