Repository: microsoft/terminal (language: cpp)

Issue:
CANARY: ALT+NUMPAD ADD is Broken
### Windows Terminal version

1.22.2334.0

### Windows build number

10.0.19045.4780

### Other Software

_No response_

### Steps to reproduce

Alt+NumpadAdd pressing combination is broken since Canary build terminal-1.22.2201.0
terminal-1.22.2191.0 - latest good
terminal-1.22.2201.0 - broken
...
terminal-1.22.2334.0 - broken

run utilities for getting codes DOWN/UP VK_CODES etc
press Alt key after press NumpadAdd and release NumpadAdd, press NumpadAdd and release NumpadAdd, press NumpadAdd and release NumpadAdd

### Expected Behavior

terminal-1.22.2191.0 - latest good:
21:42:56 KEY_EVENT_RECORD: Dn, 1, Vk="VK_ADD" [107/0x006B], Scan=0x004E uChar=[U='+' (0x002B): A='+' (0x2B)]
         Ctrl=0x00000002 (cAsac - ecns) (Windowed)
21:42:56 KEY_EVENT_RECORD: Dn, 1, Vk="VK_ADD" [107/0x006B], Scan=0x004E uChar=[U='+' (0x002B): A='+' (0x2B)]
         Ctrl=0x00000002 (cAsac - ecns) (Windowed)
21:42:57 KEY_EVENT_RECORD: Up, 1, Vk="VK_ADD" [107/0x006B], Scan=0x004E uChar=[U='+' (0x002B): A='+' (0x2B)]
         Ctrl=0x00000002 (cAsac - ecns) (Windowed)


### Actual Behavior

since terminal-1.22.2201.0  to latest canary build terminal-1.22.2334.0  is broken:

21:44:18 KEY_EVENT_RECORD: Up, 1, Vk="VK_ADD" [107/0x006B], Scan=0x004E uChar=[U='+' (0x002B): A='+' (0x2B)]
         Ctrl=0x00000002 (cAsac - ecns) (Windowed)
21:44:18 KEY_EVENT_RECORD: Up, 1, Vk="VK_ADD" [107/0x006B], Scan=0x004E uChar=[U='+' (0x002B): A='+' (0x2B)]
         Ctrl=0x00000002 (cAsac - ecns) (Windowed)
21:44:18 KEY_EVENT_RECORD: Up, 1, Vk="VK_ADD" [107/0x006B], Scan=0x004E uChar=[U='+' (0x002B): A='+' (0x2B)]
         Ctrl=0x00000002 (cAsac - ecns) (Windowed)


Discussion / hints:
with another combination I no have problem, only 100% with Alt+NumPadAdd or RAlt+NumpadAdd

if press and release only Alt/Ralt - no problem
if press and release only NumPadAdd - no problem

ps. What I found problem : my macros for FAR MANAGER  for key="AltAdd" is stop working...
Hi!, 
fix implemented in latest canary? i  check latest terminal-1.22.2371.0 - problem still exist...
@zeroes1 I believe there has been a build issue preventing Canary updates. Sorry about that.
@DHowett  ,   bad news!

I tested terminal-1.23.2391.0 now
i see what logic change, but wrong anyway :((((((

test:
i press ALT (and hold all time)

I see what generated many events like:
15:20:15 KEY_EVENT_RECORD: Dn, 1, Vk="VK_MENU" [18/0x0012], Scan=0x0038 uChar=[U=' ' (0x0000): A=' ' (0x00)]
         Ctrl=0x00000002 (cAsac - ecns) (Windowed)

after press NumAdd - any events is stopped, after I press and release NumAdd many times and I see - no any KEY EVENTS!!!

ONLY when I release ALT i see what get ALL chain events in console. It's wrong! (for example I hold ALT 1min)

terminal-1.22.2191.0 - latest good version:

test:
i press ALT (and hold all time)

generated many events like:
15:20:15 KEY_EVENT_RECORD: Dn, 1, Vk="VK_MENU" [18/0x0012], Scan=0x0038 uChar=[U=' ' (0x0000): A=' ' (0x00)]
         Ctrl=0x00000002 (cAsac - ecns) (Windowed)

after press NumAdd i see straightaway event:
15:48:19 KEY_EVENT_RECORD: Dn, 1, Vk="VK_ADD" [107/0x006B], Scan=0x004E uChar=[U='+' (0x002B): A='+' (0x2B)]
         Ctrl=0x00000002 (cAsac - ecns) (Windowed)

after release NumAdd i see straightaway event:
15:48:19 KEY_EVENT_RECORD: Up, 1, Vk="VK_ADD" [107/0x006B], Scan=0x004E uChar=[U='+' (0x002B): A='+' (0x2B)]
         Ctrl=0x00000002 (cAsac - ecns) (Windowed)

ALT is holded all times!

or may be not all PR implemented in terminal-1.23.2391.0 ?

ps. Why did the problem with Alt+Numpad appear at all??? and you can't return the code from terminal-1.22.2191.0?
I added support for `EnableHexNumpad` which allows you to enter a Unicode character with `Alt` `Numpad+` `<hex code of a character>`. I also enabled this by default because I thought it would not conflict with anything. I'll consider adding a registry key check for `EnableHexNumpad` so that it doesn't conflict for you.
@lhecker  any news?

> "I'll consider adding a registry key check for EnableHexNumpad"

I try monintoring registry RegQueryValue but no see any help
checked canary terminal-1.23.2581.0

For return old behavior I temporary use Autohotkey v2 script:
```
;Temporary Fix for Alt+NumPadAdd for Windows Terminal
HotIfWinActive "ahk_class CASCADIA_HOSTING_WINDOW_CLASS"
Hotkey "!NumpadAdd", Temp_Fix

Temp_Fix(HotkeyName)
{ 
  Send "{Alt Down}{NumpadAdd}{Alt Up}"
}
```
Ah I'm sorry. I forgot about this issue. I'll reopen it and assign myself so that I don't forget it.
Why should Alt+NumDigits affect the NumAdd at all? Shouldn't only the combinations with digits be affected?
Alt+NumpadAdd triggers the hexadecimal input of Unicode characters. You can find more information about it if you search for `EnableHexNumpad`. For instance, typing `Alt + NumpadAdd + 221E` inserts ∞.
Since we need a custom Alt+Numpad implementation, I choose to have `EnableHexNumpad` always enabled. I didn't realize that this could cause issues.

Fix patch:
diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp
index 565ea02ccf6..e2d8256ce1f 100644
--- a/src/cascadia/TerminalControl/TermControl.cpp
+++ b/src/cascadia/TerminalControl/TermControl.cpp
@@ -1631,12 +1631,29 @@ namespace winrt::Microsoft::Terminal::Control::implementation
                 {
                     if (vkey == VK_ADD)
                     {
-                        // Alt '+' <number> is used to input Unicode code points.
-                        // Every time you press + it resets the entire state
-                        // in the original OS implementation as well.
-                        s.encoding = AltNumpadEncoding::Unicode;
-                        s.accumulator = 0;
-                        s.active = true;
+                        static const auto enabled = []() {
+                            wchar_t buffer[4]{};
+                            DWORD size = sizeof(buffer);
+                            RegGetValueW(
+                                HKEY_CURRENT_USER,
+                                L"Control Panel\\Input Method",
+                                L"EnableHexNumpad",
+                                RRF_RT_REG_SZ,
+                                nullptr,
+                                &buffer[0],
+                                &size);
+                            return size == 4 && memcmp(&buffer[0], L"1", 4) == 0;
+                        }();
+
+                        if (enabled)
+                        {
+                            // Alt '+' <number> is used to input Unicode code points.
+                            // Every time you press + it resets the entire state
+                            // in the original OS implementation as well.
+                            s.encoding = AltNumpadEncoding::Unicode;
+                            s.accumulator = 0;
+                            s.active = true;
+                        }
                     }
                     else if (vkey == VK_NUMPAD0 && s.encoding == AltNumpadEncoding::OEM && s.accumulator == 0)
                     {


Test patch: