diff --git a/source/platform/terminal.cpp b/source/platform/terminal.cpp index bb3ab735..f96eabec 100644 --- a/source/platform/terminal.cpp +++ b/source/platform/terminal.cpp @@ -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]) diff --git a/source/tvision/tkey.cpp b/source/tvision/tkey.cpp index c4a6ccd0..ff00b8a2 100644 --- a/source/tvision/tkey.cpp +++ b/source/tvision/tkey.cpp @@ -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]; diff --git a/test/tvision/tkey.test.cpp b/test/tvision/tkey.test.cpp index 0984a63a..53731d37 100644 --- a/test/tvision/tkey.test.cpp +++ b/test/tvision/tkey.test.cpp @@ -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}},