Skip to content

Commit

Permalink
Do not treat AltGr as the Alt modifier when normalizing keyDown events
Browse files Browse the repository at this point in the history
  • Loading branch information
magiblot committed Oct 20, 2024
1 parent bef194f commit 0d09e95
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions source/platform/terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ void TermIO::keyModsOff(StdioCtl &io) noexcept
void TermIO::normalizeKey(KeyDownEvent &keyDown) noexcept
{
TKey key(keyDown);
if (key.mods & (kbShift | kbCtrlShift | kbAltShift))
if (key.mods & (kbShift | kbCtrlShift | kbLeftAlt))
{
// Modifier precedece: Shift < Ctrl < Alt.
int largestMod = (key.mods & kbAltShift) ? 2
int largestMod = (key.mods & kbLeftAlt) ? 2
: (key.mods & kbCtrlShift) ? 1
: 0;
if (ushort keyCode = moddedKeyCodes[key.code][largestMod])
Expand Down
4 changes: 2 additions & 2 deletions source/tvision/tkey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,14 @@ TKey::TKey(ushort keyCode, ushort shiftState) noexcept
ushort mods =
(shiftState & kbShift ? kbShift : 0) |
(shiftState & kbCtrlShift ? kbCtrlShift : 0) |
(shiftState & kbAltShift ? kbAltShift : 0);
(shiftState & kbLeftAlt ? kbAltShift : 0);
uchar scanCode = keyCode >> 8;
uchar charCode = keyCode & 0xFF;

const TKeyCodeLookupEntry *entry = 0;
if (keyCode <= kbCtrlZ || isRawCtrlKey(scanCode, charCode))
entry = &ctrlKeyLookup[charCode];
else if ((keyCode & 0xFF) == 0)
else if (charCode == 0)
{
if (scanCode < extKeyLookupSize)
entry = &extKeyLookup[scanCode];
Expand Down
1 change: 1 addition & 0 deletions test/tvision/tkey.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ TEST(TKey, ShouldConstructProperly)
{{'A', kbCtrlShift | kbAltShift}, {'A', kbCtrlShift | kbAltShift}},
{{'A', kbShift | kbCtrlShift | kbAltShift}, {'A', kbShift | kbCtrlShift | kbAltShift}},
{{'a'}, {'A'}},
{{'a', kbRightAlt}, {'A'}},
{{'a', kbShift}, {'A', kbShift}},
{{'a', kbCtrlShift}, {'A', kbCtrlShift}},
{{'a', kbShift | kbCtrlShift}, {'A', kbShift | kbCtrlShift}},
Expand Down

0 comments on commit 0d09e95

Please sign in to comment.