feat: add Shift+ modifier support for keybinds (#3679)

## Description:

This PR adds support for `Shift+<key>` keybind combinations across the
entire keybind system.

Previously, keybinds only supported a single key (e.g. `KeyB` for boat
attack). Now any keybind can be configured as `Shift+KeyB`, which will
only trigger when Shift is held down simultaneously.

Enables to use Shift + A for "select all" feature from #3677 

**Changes:**
- `InputHandler.ts`: Added `parseKeybind()` helper that parses
`"Shift+KeyB"` → `{ shift: true, code: "KeyB" }`. Added
`keybindMatchesEvent()` for consistent matching across all keyup/keydown
handlers. Updated `resolveBuildKeybind()` and all keybind comparisons to
respect the shift modifier.
- `SettingKeybind.ts`: When recording a keybind, lone modifier keys
(Shift, Ctrl, etc.) are skipped — the component waits for the actual
key. If Shift is held when the key is pressed, the value is stored as
`"Shift+<code>"`.
- `Utils.ts`: `formatKeyForDisplay()` now handles the `Shift+` prefix,
displaying e.g. `"Shift+B"`.
- `tests/InputHandler.test.ts`: Added 6 tests covering Shift+ keybind
matching, negative cases (plain key not triggering Shift-bound action),
coexistence of `Digit1` and `Shift+Digit1` on different actions, and
Numpad alias support with Shift.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## UI changes:

<img width="2255" height="2070" alt="CleanShot 2026-04-15 at 20 23
25@2x"
src="https://github.com/user-attachments/assets/96c19fc3-6294-40b7-82eb-3fde52b71618"
/>


## Please put your Discord username so you can be contacted if a bug or
regression is found:

fghjk_60845
This commit is contained in:
Ivan Batsulin
2026-04-17 05:46:01 +03:00
committed by GitHub
parent d0a9146843
commit e5e1211480
6 changed files with 236 additions and 21 deletions
@@ -100,17 +100,32 @@ export class SettingKeybind extends LitElement {
return;
}
// Don't capture lone modifier keys — wait for the actual key
if (
e.code === "ShiftLeft" ||
e.code === "ShiftRight" ||
e.code === "ControlLeft" ||
e.code === "ControlRight" ||
e.code === "AltLeft" ||
e.code === "AltRight" ||
e.code === "MetaLeft" ||
e.code === "MetaRight"
) {
return;
}
// Prevent default only for keys we're actually capturing
e.preventDefault();
const code = e.code;
const code = e.shiftKey ? `Shift+${e.code}` : e.code;
const displayKey = e.shiftKey ? `Shift+${e.key.toUpperCase()}` : e.key;
const prevValue = this.value;
// Temporarily set the value to the new code for validation in parent
this.value = code;
const event = new CustomEvent("change", {
detail: { action: this.action, value: code, key: e.key, prevValue },
detail: { action: this.action, value: code, key: displayKey, prevValue },
bubbles: true,
composed: true,
});