diff --git a/src/host/inputBuffer.cpp b/src/host/inputBuffer.cpp index 3a4e556e4405..b61f643a08e5 100644 --- a/src/host/inputBuffer.cpp +++ b/src/host/inputBuffer.cpp @@ -816,7 +816,9 @@ void InputBuffer::_HandleTerminalInputCallback(const TerminalInput::StringType& for (const auto& wch : text) { - _storage.push_back(SynthesizeKeyEvent(true, 1, 0, 0, wch, 0)); + // We can't get a null byte without the control key. Can we? + uint32_t dwControlKeyState = (wch == 0) ? CTRL_PRESSED : 0; + _storage.push_back(SynthesizeKeyEvent(true, 1, 0, 0, wch, dwControlKeyState)); } if (!_vtInputShouldSuppress) diff --git a/src/host/stream.cpp b/src/host/stream.cpp index 11a7f6a4115c..962f835de65f 100644 --- a/src/host/stream.cpp +++ b/src/host/stream.cpp @@ -233,10 +233,11 @@ static bool IsCommandLineEditingKey(const KEY_EVENT_RECORD& event) const auto zeroKey = OneCoreSafeVkKeyScanW(0); - if (LOBYTE(zeroKey) == Event.Event.KeyEvent.wVirtualKeyCode && - WI_IsAnyFlagSet(Event.Event.KeyEvent.dwControlKeyState, ALT_PRESSED) == WI_IsFlagSet(zeroKey, 0x400) && - WI_IsAnyFlagSet(Event.Event.KeyEvent.dwControlKeyState, CTRL_PRESSED) == WI_IsFlagSet(zeroKey, 0x200) && - WI_IsAnyFlagSet(Event.Event.KeyEvent.dwControlKeyState, SHIFT_PRESSED) == WI_IsFlagSet(zeroKey, 0x100)) + if ((LOBYTE(zeroKey) == Event.Event.KeyEvent.wVirtualKeyCode && + WI_IsAnyFlagSet(Event.Event.KeyEvent.dwControlKeyState, ALT_PRESSED) == WI_IsFlagSet(zeroKey, 0x400) && + WI_IsAnyFlagSet(Event.Event.KeyEvent.dwControlKeyState, CTRL_PRESSED) == WI_IsFlagSet(zeroKey, 0x200) && + WI_IsAnyFlagSet(Event.Event.KeyEvent.dwControlKeyState, SHIFT_PRESSED) == WI_IsFlagSet(zeroKey, 0x100)) || + (Event.Event.KeyEvent.wVirtualKeyCode == 0 && WI_IsAnyFlagSet(Event.Event.KeyEvent.dwControlKeyState, CTRL_PRESSED))) { // This really is the character 0x0000 *pwchOut = Event.Event.KeyEvent.uChar.UnicodeChar;