• You are not logged in.

    Phantom Key Messages in WPF

    • Started by CodeRush
    • 1 Replies:
    • Reputation: 0
    • Registered: 18-Nov-2023
    • Posts: 1

    I'm a developer building an application using C# and WPF in Visual Studio. In this environment I noticed a bug where phantom key messages are sent that seems to be only reproducible when the Colemak layout is active.

    Steps to reproduce:

    1. Create a new WPF application in Visual Studio
    2. Replace the MainWindow.xaml file contents with the xaml here.
    3. Replace the MainWindow.xaml.cs file contents with the C# code here.
    4. Run.
    5. Press and hold the right Ctrl key.
    6. Press and hold the right Alt key.
    7. Release the right Alt key.
    8. Look at the text in the TextBox. I see this output (minus the comments) for each step above:

    // Hold down the Right Ctrl key:

        Down: RightCtrl + [Control]

    // Now also hold down the Right Alt key:

        Down: RightAlt + [Alt, Control]

    // Now release the right Alt key:
        Up: LeftCtrl + [Alt, Control]  // << Why this? Left Ctrl key was never pressed or released.
        Up: RightAlt + [Control]

    // Now release the right Ctrl key:
        Up: RightCtrl + [None]

    If I run this sequence under a normal keyboard layout I see only the expected keys that were pressed and released:

    Down: RightCtrl + [Control]
    Down: RightAlt + [Alt, Control]
    Up: RightAlt + [Control]
    Up: RightCtrl + [None]

    Last edited by CodeRush (18-Nov-2023 16:35:22)
    Offline
    • 0
    • Reputation: 214
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,364

    Your post seems thorough, and yet it omits one crucial piece of information: Your platform/implementation.

    What OS is this? And how did you get Colemak on it? As you may have noticed there are many ways to change your layout: On Windows, for instance, there's the MSKLC OS install (if so, from which file?), Autohotkey, EPKL (my program), registry remapping, etc etc...

    To me, it looks like you've run afoul of the AltGr key. Four-level layouts like many Euro/Intl. ones use RAlt (technically sending RAlt+LCtrl) as the layer switch modifier, whereas the plain US layout has it as simply another Alt key (key code E0_32, iirc). Your software may be unable to distinguish the two, as is sometimes the case with sloppily written software.

    One way to remedy this is to use a non-AltGr layout install, if you're on Windows using a MSKLC layout. In my EPKL program there's an Other\MSKLC folder containing such a file that you could download and install separately if you wish.

    https://github.com/DreymaR/BigBagKbdTri … ther/MSKLC

    Last edited by DreymaR (20-Nov-2023 10:45:30)

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0