views:

654

answers:

4

I have a keyboard event listener, and I am listening for the number pad key codes (1 through 9) for when number lock is activated; this works fine. However, in my app I also want to allow usage of a modifier key (CTRL) along with the number pad keys. The strange thing is that when holding CTRL, pressing 1 or 3 does not generate any keyboard event whatsoever, whereas 2 and 4 - 9 do generate the expected events. I have seen other references to this issue after some Googling, so I do not believe this is necessarily Flash-specific, but I have yet to find any answers.

I tried using SHIFT as a modifier, but that just results in generating the key codes from the number pad as if number lock was off (eg, SHIFT+Numpad1 returns the End keycode, regardless of number lock state) - apparently this is intentional Windows behavior. ALT is not an option with the numpad due to altcodes.

Any ideas on how to get CTRL+Numpad1 and CTRL+Numpad3 to generate the keyboard events? Or any explanation as to why they don't?

Edit: I tried out using these key combinations in Firefox as enriquein suggests below, and all the key combinations work A-OK, leading me to believe that this is likely a Flash-specific issue, or at least not a hardware issue.

A: 

I have run into issues in the past with numpad keys on specific keyboards. Various key combinations fail to register on specific keyboards, and it is possible that the keyboard you are using may just not be generating any event in that case. It's not guaranteed to work, but I would recommend trying out a different keyboard (different vendor, etc) and see if that works. It also might be an issue with localized keyboards, if you are using a non-english keyboard.

JZig
+2  A: 

I'm almost certain it's not Flash related because I had similar problems with a localized keyboard and could not get it to generate events at all for certain keys or key combinations.

Try enumerating all key events and searching trough what they're mapped to, or google evtest.c, compile it and run it and see what it has to say.

Vuk
This is on Windows, evtest.c looks like it's Unix-only.
Not Sure
Yup, Unix-specific code, you're right, sorry 'bout that. Maybe if you boot a live linux distro just to run those few tests.
Vuk
A: 

Indeed it looks like its keyboard specific. I tried the key combinations as I read this question in Firefox and they triggered the same event as pressing Ctrl+Number (which is switch to tab #Number).

This was using a standard US/101-key english keyboard (no extra media buttons or anything).

enriquein
I did not know Firefox had that behavior - I just tried it out, and CTRL+Numpad1 and Numpad3 work fine. Perhaps this is a flash-specific problem...
Not Sure
A: 

Some keyboards don't register certain key combinations. I think that this is down to how they are put together. For example some may register left hand Ctrl + key combination but not right Ctrl + same key!

A work around would be to detect the key down and key up events for the Ctrl key.

You could then raise a custom event for Ctrl + numpad key or work with a volatile flag to show the Ctrl key state.

ChrisBD