Commit e5e1211
authored
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_608451 parent d0a9146 commit e5e1211
File tree
6 files changed
+236
-21
lines changed- resources/lang
- src/client
- components/baseComponents/setting
- tests
6 files changed
+236
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
545 | 545 | | |
546 | 546 | | |
547 | 547 | | |
| 548 | + | |
548 | 549 | | |
549 | 550 | | |
550 | 551 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | | - | |
| 284 | + | |
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
292 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
293 | 296 | | |
294 | 297 | | |
295 | 298 | | |
| |||
375 | 378 | | |
376 | 379 | | |
377 | 380 | | |
378 | | - | |
| 381 | + | |
379 | 382 | | |
380 | 383 | | |
381 | 384 | | |
| |||
387 | 390 | | |
388 | 391 | | |
389 | 392 | | |
390 | | - | |
| 393 | + | |
391 | 394 | | |
392 | 395 | | |
393 | 396 | | |
394 | 397 | | |
395 | | - | |
| 398 | + | |
396 | 399 | | |
397 | 400 | | |
398 | 401 | | |
399 | 402 | | |
400 | | - | |
| 403 | + | |
401 | 404 | | |
402 | 405 | | |
403 | 406 | | |
404 | 407 | | |
405 | 408 | | |
406 | | - | |
| 409 | + | |
407 | 410 | | |
408 | 411 | | |
409 | 412 | | |
410 | 413 | | |
411 | 414 | | |
412 | | - | |
| 415 | + | |
413 | 416 | | |
414 | 417 | | |
415 | 418 | | |
416 | 419 | | |
417 | 420 | | |
418 | | - | |
| 421 | + | |
419 | 422 | | |
420 | 423 | | |
421 | 424 | | |
422 | 425 | | |
423 | 426 | | |
424 | | - | |
| 427 | + | |
425 | 428 | | |
426 | 429 | | |
427 | 430 | | |
428 | 431 | | |
429 | 432 | | |
430 | | - | |
| 433 | + | |
431 | 434 | | |
432 | 435 | | |
433 | 436 | | |
434 | | - | |
| 437 | + | |
435 | 438 | | |
436 | 439 | | |
437 | 440 | | |
438 | | - | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
439 | 445 | | |
440 | 446 | | |
441 | 447 | | |
| |||
615 | 621 | | |
616 | 622 | | |
617 | 623 | | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
618 | 645 | | |
619 | 646 | | |
620 | 647 | | |
| |||
637 | 664 | | |
638 | 665 | | |
639 | 666 | | |
640 | | - | |
641 | | - | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
642 | 674 | | |
643 | 675 | | |
644 | 676 | | |
645 | 677 | | |
646 | 678 | | |
| 679 | + | |
647 | 680 | | |
648 | 681 | | |
| 682 | + | |
| 683 | + | |
649 | 684 | | |
650 | | - | |
| 685 | + | |
651 | 686 | | |
652 | 687 | | |
653 | 688 | | |
654 | 689 | | |
655 | 690 | | |
656 | 691 | | |
657 | 692 | | |
658 | | - | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
659 | 697 | | |
660 | 698 | | |
661 | 699 | | |
| |||
672 | 710 | | |
673 | 711 | | |
674 | 712 | | |
675 | | - | |
| 713 | + | |
| 714 | + | |
676 | 715 | | |
677 | 716 | | |
678 | | - | |
| 717 | + | |
| 718 | + | |
679 | 719 | | |
680 | 720 | | |
681 | 721 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
383 | 383 | | |
384 | 384 | | |
385 | 385 | | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
386 | 406 | | |
387 | 407 | | |
388 | 408 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
317 | 322 | | |
318 | 323 | | |
319 | 324 | | |
| |||
Lines changed: 17 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
103 | 117 | | |
104 | 118 | | |
105 | 119 | | |
106 | | - | |
| 120 | + | |
| 121 | + | |
107 | 122 | | |
108 | 123 | | |
109 | 124 | | |
110 | 125 | | |
111 | 126 | | |
112 | 127 | | |
113 | | - | |
| 128 | + | |
114 | 129 | | |
115 | 130 | | |
116 | 131 | | |
| |||
0 commit comments