Skip to content
This repository has been archived by the owner on Jan 16, 2018. It is now read-only.

Incorrect keyboard event key codes for the function and numpad keys #193

Closed
jgranick opened this issue Feb 28, 2014 · 9 comments
Closed

Comments

@jgranick
Copy link
Member

#193 Issue by Gama11,

This issue has been around for quite a while. On native targets, the KeyboardEvent keycodes for numpad and function keys are inconsistent with their flash counterparts.

KeyboardEvent.keyCode Flash Native (cpp + neko)
F1-F11 112-122 80-90
F12 123 123
Numpad 0-9 96-105 64-73
Numlock 144 -1073741741 (I'm not kidding)
Numpad / 111 79
Numpad * 106 74
Numpad - 109 77
Numpad + 107 75
Numpad Del 110 78
Pause 19 -1073741752
Scroll lock 145 -1073741753
Print Scrn none -1073741754

Obviously, this is quite problematic.

@jgranick
Copy link
Member Author

jgranick commented Mar 5, 2014

Comment by ibilon:

In haxepunk we maintain a Map with code in native and their "real" flash value.
That's not optimal but at least it's working for most keys.
https://github.com/HaxePunk/HaxePunk/blob/dev/com/haxepunk/utils/Input.hx#L316

Of course this is just a temp hack, unified key code for all openfl targets would be great.

@jgranick
Copy link
Member Author

jgranick commented Mar 5, 2014

Comment by Gama11:

That's clever... Mind if we steal that for HaxeFlixel? ;)

@jgranick
Copy link
Member Author

jgranick commented Mar 5, 2014

Comment by ibilon:

No problem ;)

@jgranick
Copy link
Member Author

Comment by jgranick:

If anyone wanted to attempt a pull request, this is a terrible difficult fix to do, its more a matter of testing it. There is an "SDLKeyToFlash" function in "/project/src/backend/sdl2/SDL2Stage.cpp" that handles the mapping for desktop targets. This is mostly a matter of taking the time to test and compare to ensure it looks consistent. Thanks!

@jgranick
Copy link
Member Author

Comment by ibilon:

I'll give it a try :)

@jgranick
Copy link
Member Author

Comment by ibilon:

I've made a pull request,
it fixes a lot a keys, including all mentioned by @Gama11

Just a couple of things:

  • I have Numpad Del at 46 not 110
  • I made up two codes for: (to avoid ridiculously big numbers)
    • Print Screen 301
    • Application 302
  • The numpad keys were the same whether the lock was on or not (always on)

There was a lot of keys that should work on a qwerty keyboard but didn't on my azerty,
seems SDLKeyToFlash doesn't get the right value,
if that's the case then all 144 keys I tried should have the same code in flash and native (on a qwerty at least).

@jgranick
Copy link
Member Author

Comment by Gama11:

Things still seem to be broken on my qwertz keyboard. The only things that were fixed by this are pageup, pagedown and insert it seems. :/ So that means then ative key correction workaround is still required.

@jgranick
Copy link
Member Author

Comment by ibilon:

Did you use the second pull request, the one not yet merged?

@jgranick
Copy link
Member Author

Comment by Gama11:

I just used the current haxelib releases. Didn't release part of it has not been merged yet.

@jgranick jgranick mentioned this issue Jan 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant