Merge pull request #2206 from ESWAT/keybind-cycle-lobbies

Add keybinds for cycling through networks/lobbies
This commit is contained in:
Jérémie Astori 2018-03-16 01:37:22 -04:00 committed by GitHub
commit 49f1a01dba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 0 deletions

View file

@ -57,6 +57,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() {

View file

@ -47,6 +47,15 @@
<h2>Keyboard Shortcuts</h2>
<div class="help-item">
<div class="subject">
<kbd class="key-all">Alt</kbd><kbd class="key-apple">⌥</kbd> + <kbd>Shift</kbd> + <kbd>↑</kbd> / <kbd>↓</kbd>
</div>
<div class="description">
<p>Switch to the previous/next lobby in the channel list.</p>
</div>
</div>
<div class="help-item">
<div class="subject">
<kbd class="key-all">Alt</kbd><kbd class="key-apple">⌥</kbd> + <kbd>↑</kbd> / <kbd>↓</kbd>