@@ -227,16 +227,24 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
227227 }
228228 }
229229
230- // Special case for forward slash and semicolon.
231- // Unfortunately their virtual key codes are not unique and can vary between languages, so this only works for US keyboard layouts.
232- // See: https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
233- if (!wcscmp (context->locale , L" en-US" )) {
234- bool shift_down = (GetKeyState (VK_SHIFT ) & 0x80 ) != 0 ;
235- if (wparam == 0xBF && !shift_down) {
236- NvimSendSysChar (context->nvim , L' /' );
230+ bool shift_down = (GetKeyState (VK_SHIFT ) & 0x80 ) != 0 ;
231+ if (!shift_down) {
232+ // Allow Nvim to recognize <C-[0-9]>.
233+ // 0x30 is the virtual key code for 0, 0x39 is the virtual key code for 9, and the other numbers are in-between.
234+ if (0x30 <= wparam && wparam <= 0x39 ) {
235+ NvimSendSysChar (context->nvim , static_cast <wchar_t >(wparam));
237236 }
238- if (wparam == 0xBA && !shift_down) {
239- NvimSendSysChar (context->nvim , L' ;' );
237+
238+ // Special case for forward slash and semicolon.
239+ // Unfortunately their virtual key codes are not unique and can vary between languages, so this only works for US keyboard layouts.
240+ // See: https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
241+ if (!wcscmp (context->locale , L" en-US" )) {
242+ if (wparam == 0xBF ) {
243+ NvimSendSysChar (context->nvim , L' /' );
244+ }
245+ if (wparam == 0xBA ) {
246+ NvimSendSysChar (context->nvim , L' ;' );
247+ }
240248 }
241249 }
242250
0 commit comments