Skip to content

ALT+ENTER will cause the subsequent keystroke to get swallowed #28

Closed

Description

@clangen

If the user presses ALT+ENTER, the keystroke after will be swallowed. It seems to have something to do with this commit: Bill-Gray/PDCurses@84db661

I don't understand the inner workings of key handling enough to suggest an elegant solution, but I seem to be able to work around it by ALSO remembering the last keycode that was processed, i.e:

static bool key_already_handled = FALSE;
static int last_key_handled = 0; /* added this */

then...

if (wParam == VK_MULTIPLY || wParam == VK_DIVIDE
    || wParam == VK_ADD || wParam == VK_SUBTRACT
    || wParam == VK_RETURN) {
        last_key_handled = key;
        key_already_handled = TRUE; /* added this */
    }
}

and finally...

    case WM_CHAR:       /* _Don't_ add Shift-Tab;  it's handled elsewhere */
        if( wParam != 9 || !(GetKeyState( VK_SHIFT) & 0x8000))
            if( !key_already_handled || last_key_handled != (int)wParam ) /* modified this */
               add_key_to_queue( (int)wParam );
        key_already_handled = FALSE;
        last_key_handled = 0; /* added this */
        break;

However, (1) it feels dirty, and (2) I have a feeling it may re-introduce the original bug. I don't currently have a keyboard with a numpad handy to test it out.

Activity

  1. Bill-Gray commented on Mar 15, 2017

    @Bill-Gray
    Owner

    Yup, that's a bug... same misbehavior here, in both 'newtest' and 'testcurs'. Thanks for pointing this out.

    Unfortunately, the key-handling code has gathered a lot of barnacles, to the point where the way it works is no longer all that obvious to me, even though I wrote some of it (much was recycled from Win32 console, as I recall.) I'll give it a look-over... unfortunately, it may be a while; the "day job" is heating up a bit.

  2. GitMensch commented on Dec 24, 2018

    @GitMensch
    Collaborator

    @Bill-Gray Do you see clangen@a4a5ec7 fixing this and may merge + close this issue?

  3. added a commit that references this issue on Dec 27, 2018
  4. Bill-Gray commented on Dec 27, 2018

    @Bill-Gray
    Owner

    Figured it out. Marking key_already_handled = TRUE is necessary for the pad-multiply, sub, div, add, and Enter keys... unless Alt is held down. It wasn't just Alt-Enter that was messed up; it was Alt-all of those keys. (Except Alt-Padplus, which is used for Unicode entry and was handled elsewhere anyway.)
    Hit any of those four Alt-Pad keys, and key_already_handled was set to TRUE... but no extra character was sent to be ignored. Instead, the next key hit was ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions