The scancode returned in KEY_EVENT_RECORD don't match over ssh #7399

Open
opened 2026-01-31 01:02:56 +00:00 by claunia · 0 comments
Owner

Originally created by @taviso on GitHub (Apr 13, 2020).

Environment

Windows build number: Microsoft Windows [Version 10.0.18363.720]

C:\>ssh -V # Note, this is the ssh binary that comes with Windows 10
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5

Steps to reproduce

I'm trying to use the console application hiew, it works perfectly in console but behaves differently over ssh, some keys are recognized incorrectly. I wrote a quick test program to dump keyboard events from ReadConsoleInput() and found that the only difference is that the wVirtualScanCode is different.

Example pressing the 'a' key locally in cmd:

Key event: 
 bKeyDown:          0
 wRepeatCount:      1
 wVirtualKeyCode:   65
 wVirtualScanCode:  30
 uChar:
  UnicodeChar:      'a' (0x61)
  AsciiChar:        'a' (0x61)
 dwControlKeyState: 0

Over ssh I get this:

Key event:  
 bKeyDown:          0
 wRepeatCount:      1
 wVirtualKeyCode:   65
 wVirtualScanCode:  79
 uChar:
  UnicodeChar:      'a' (0x61)
  AsciiChar:        'a' (0x61)
 dwControlKeyState: 0

I've verified that if I attach to the program in windbg, and patch up the scan code in the KEY_EVENT_RECORD structures after ReadConsoleInput() returns, the program works perfectly.

Expected behavior

I think the wVirtualScanCode should match locally and over ssh.

Actual behavior

The wVirtualScanCode are wildly different, and applications that examine them become confused.

If there is a setting somewhere that configured this, I wasn't able to find it, I really tried!

Originally created by @taviso on GitHub (Apr 13, 2020). # Environment ```none Windows build number: Microsoft Windows [Version 10.0.18363.720] C:\>ssh -V # Note, this is the ssh binary that comes with Windows 10 OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5 ``` # Steps to reproduce I'm trying to use the console application [hiew](http://www.hiew.ru/), it works perfectly in console but behaves differently over ssh, some keys are recognized incorrectly. I wrote a quick test program to dump keyboard events from `ReadConsoleInput()` and found that the only difference is that the `wVirtualScanCode` is different. Example pressing the 'a' key locally in cmd: ``` Key event: bKeyDown: 0 wRepeatCount: 1 wVirtualKeyCode: 65 wVirtualScanCode: 30 uChar: UnicodeChar: 'a' (0x61) AsciiChar: 'a' (0x61) dwControlKeyState: 0 ``` Over ssh I get this: ``` Key event: bKeyDown: 0 wRepeatCount: 1 wVirtualKeyCode: 65 wVirtualScanCode: 79 uChar: UnicodeChar: 'a' (0x61) AsciiChar: 'a' (0x61) dwControlKeyState: 0 ``` I've verified that if I attach to the program in windbg, and patch up the scan code in the `KEY_EVENT_RECORD` structures after `ReadConsoleInput()` returns, the program works perfectly. # Expected behavior I think the `wVirtualScanCode` should match locally and over ssh. # Actual behavior The `wVirtualScanCode` are wildly different, and applications that examine them become confused. If there is a setting somewhere that configured this, I wasn't able to find it, I really tried!
claunia added the Resolution-DuplicateProduct-Conpty labels 2026-01-31 01:02:56 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#7399