[PR #5021] Add enhanced key support for ConPty #26086

Open
opened 2026-01-31 09:13:49 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/5021

State: closed
Merged: Yes


Summary of the Pull Request

ConPty did not set the ENHANCED_KEY flag when generating new input. This change helps detect when it's supposed to do so, and sends it.

References

Enhanced Key Documentation

PR Checklist

Detailed Description of the Pull Request / Additional comments

KEY_EVENT_RECORD modifiers VT encodable? Detectable on the way out?
CAPSLOCK_ON No No
ENHANCED_KEY No Yes**
LEFT_ALT_PRESSED Yes* Yes*
LEFT_CTRL_PRESSED Yes* Yes*
NUMLOCK_ON No No
RIGHT_ALT_PRESSED Yes* Yes*
RIGHT_CTRL_PRESSED Yes* Yes*
SCROLLLOCK_ON No No
SHIFT_PRESSED Yes Yes
* We can detect Alt and Ctrl, but not necessarily which one
** Enhanced Keys are limited to the following:
    - off keypad: INS, DEL, HOME, END, PAGE UP, PAGE DOWN, direction keys
    - on keypad: / and ENTER
   Since we can't detect the keypad keys, those will _not_ send the ENHANCED_KEY modifier.
   For the following CSI action codes, we can assume that they are Enhanced Keys:
     case CsiActionCodes::ArrowUp:
     case CsiActionCodes::ArrowDown:
     case CsiActionCodes::ArrowRight:
     case CsiActionCodes::ArrowLeft:
     case CsiActionCodes::Home:
     case CsiActionCodes::End:
     case CsiActionCodes::CSI_F1:
     case CsiActionCodes::CSI_F3:
     case CsiActionCodes::CSI_F2:
     case CsiActionCodes::CSI_F4:
   These cases are handled in ActionCsiDispatch

Validation Steps Performed

Followed bug repro steps. It now matches!

**Original Pull Request:** https://github.com/microsoft/terminal/pull/5021 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request ConPty did not set the ENHANCED_KEY flag when generating new input. This change helps detect when it's supposed to do so, and sends it. ## References [Enhanced Key Documentation](https://docs.microsoft.com/en-us/windows/console/key-event-record-str) ## PR Checklist * [X] Closes #2397 ## Detailed Description of the Pull Request / Additional comments | KEY_EVENT_RECORD modifiers | VT encodable? | Detectable on the way out? | |----------------------------|---------------|----------------------------| | CAPSLOCK_ON | No | No | | ENHANCED_KEY | No | Yes** | | LEFT_ALT_PRESSED | Yes* | Yes* | | LEFT_CTRL_PRESSED | Yes* | Yes* | | NUMLOCK_ON | No | No | | RIGHT_ALT_PRESSED | Yes* | Yes* | | RIGHT_CTRL_PRESSED | Yes* | Yes* | | SCROLLLOCK_ON | No | No | | SHIFT_PRESSED | Yes | Yes | ``` * We can detect Alt and Ctrl, but not necessarily which one ** Enhanced Keys are limited to the following: - off keypad: INS, DEL, HOME, END, PAGE UP, PAGE DOWN, direction keys - on keypad: / and ENTER Since we can't detect the keypad keys, those will _not_ send the ENHANCED_KEY modifier. For the following CSI action codes, we can assume that they are Enhanced Keys: case CsiActionCodes::ArrowUp: case CsiActionCodes::ArrowDown: case CsiActionCodes::ArrowRight: case CsiActionCodes::ArrowLeft: case CsiActionCodes::Home: case CsiActionCodes::End: case CsiActionCodes::CSI_F1: case CsiActionCodes::CSI_F3: case CsiActionCodes::CSI_F2: case CsiActionCodes::CSI_F4: These cases are handled in ActionCsiDispatch ``` ## Validation Steps Performed Followed bug repro steps. It now matches!
claunia added the pull-request label 2026-01-31 09:13:49 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26086