diff --git a/play.pokemonshowdown.com/src/client-main.ts b/play.pokemonshowdown.com/src/client-main.ts index c0a20a5e9..96b3bfa9a 100644 --- a/play.pokemonshowdown.com/src/client-main.ts +++ b/play.pokemonshowdown.com/src/client-main.ts @@ -2405,6 +2405,21 @@ export const PS = new class extends PSModel { } return this.focusRoom(rooms[index + 1]); } + focusUnreadRoom(direction: 'left' | 'right') { + const { rooms, index } = this.horizontalNav(); + if (index === -1) return; + + const unreadRooms = rooms.filter((room, i) => + PS.rooms[room]?.isSubtleNotifying && + (direction === 'left' ? i < index : i > index) + ); + + if (!unreadRooms.length) return; + + const target = direction === 'left' ? unreadRooms[unreadRooms.length - 1] : unreadRooms[0]; + + return this.focusRoom(target); + } alert(message: string, opts: { okButton?: string, parentElem?: HTMLElement | null, width?: number } = {}) { this.join(`popup-${this.popups.length}` as RoomID, { args: { message, ...opts, parentElem: null }, diff --git a/play.pokemonshowdown.com/src/panel-chat.tsx b/play.pokemonshowdown.com/src/panel-chat.tsx index 2f2a28743..666c69110 100644 --- a/play.pokemonshowdown.com/src/panel-chat.tsx +++ b/play.pokemonshowdown.com/src/panel-chat.tsx @@ -934,6 +934,7 @@ export class ChatTextEntry extends preact.Component<{ } handleKey(ev: KeyboardEvent) { const cmdKey = ((ev.metaKey ? 1 : 0) + (ev.ctrlKey ? 1 : 0) === 1) && !ev.altKey && !ev.shiftKey; + const altKey = ev.altKey; // const anyModifier = ev.ctrlKey || ev.altKey || ev.metaKey || ev.shiftKey; if (ev.keyCode === 13 && !ev.shiftKey) { // Enter key return this.submit(); @@ -965,7 +966,7 @@ export class ChatTextEntry extends preact.Component<{ // const newValue = `/pm ${PS.user.lastPM}, `; // this.setValue(newValue, newValue.length); // return true; - } else if (ev.shiftKey && ev.keyCode === 37) { + } else if (ev.shiftKey && ev.keyCode === 37 && !altKey) { if (PS.prefs.onepanel === 'vertical' || this.getValue().length > 0) return; const curLoc = PS.room.location; let newLoc = curLoc; @@ -1002,7 +1003,7 @@ export class ChatTextEntry extends preact.Component<{ PS.update(); } return true; - } else if (ev.shiftKey && ev.keyCode === 39) { + } else if (ev.shiftKey && ev.keyCode === 39 && !altKey) { if (PS.prefs.onepanel === 'vertical' || this.getValue().length > 0) return; const curLoc = PS.room.location; let newLoc = curLoc; diff --git a/play.pokemonshowdown.com/src/panels.tsx b/play.pokemonshowdown.com/src/panels.tsx index 0749f3708..dcc57ef35 100644 --- a/play.pokemonshowdown.com/src/panels.tsx +++ b/play.pokemonshowdown.com/src/panels.tsx @@ -542,6 +542,13 @@ export class PSView extends preact.Component { } const modifierKey = ev.ctrlKey || ev.altKey || ev.metaKey || ev.shiftKey; const altKey = !ev.ctrlKey && ev.altKey && !ev.metaKey && !ev.shiftKey; + if (ev.altKey && ev.shiftKey && ev.keyCode === 37) { // alt + shift + left + PS.arrowKeysUsed = true; + PS.focusUnreadRoom('left'); + } else if (ev.altKey && ev.shiftKey && ev.keyCode === 39) { // alt + shift + right + PS.arrowKeysUsed = true; + PS.focusUnreadRoom('right'); + } if (altKey && ev.keyCode === 38) { // alt + up PS.arrowKeysUsed = true; PS.focusUpRoom();