From c0f430e5096e430190d441fa32a083f659ea5d47 Mon Sep 17 00:00:00 2001 From: Philip Karpiak Date: Thu, 15 Mar 2018 10:10:20 -0400 Subject: [PATCH] Add keybinds for cycling through networks/lobbies --- client/js/keybinds.js | 32 ++++++++++++++++++++++++++++++++ client/views/windows/help.tpl | 9 +++++++++ 2 files changed, 41 insertions(+) diff --git a/client/js/keybinds.js b/client/js/keybinds.js index f36fc67b..11c94d3f 100644 --- a/client/js/keybinds.js +++ b/client/js/keybinds.js @@ -58,6 +58,38 @@ Mousetrap.bind([ channels.eq(target).click(); }); +Mousetrap.bind([ + "alt+shift+up", + "alt+shift+down", +], function(e, keys) { + const lobbies = sidebar.find(".lobby"); + const direction = keys.split("+").pop(); + let index = lobbies.index(lobbies.filter(".active")); + let target; + + switch (direction) { + case "up": + if (index < 0) { + target = lobbies.index(sidebar.find(".channel").filter(".active").siblings(".lobby")[0]); + } else { + target = (lobbies.length + (index - 1 + lobbies.length)) % lobbies.length; + } + + break; + + case "down": + if (index < 0) { + index = lobbies.index(sidebar.find(".channel").filter(".active").siblings(".lobby")[0]); + } + + target = (lobbies.length + (index + 1 + lobbies.length)) % lobbies.length; + + break; + } + + lobbies.eq(target).click(); +}); + Mousetrap.bind([ "escape", ], function() { diff --git a/client/views/windows/help.tpl b/client/views/windows/help.tpl index 22a7e2ef..e97cd92e 100644 --- a/client/views/windows/help.tpl +++ b/client/views/windows/help.tpl @@ -47,6 +47,15 @@

Keyboard Shortcuts

+
+
+ Alt + Shift + / +
+
+

Switch to the previous/next lobby in the channel list.

+
+
+
Alt + /