Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / Html5 doesn't support numeric keypad?

Author
Message
Prime
1
Years of Service
User Offline
Joined: 15th Jun 2022
Location:
Posted: 23rd Jul 2022 22:18
I'm having trouble using the numeric keypad on my keyboard to input numbers in the html5 version of my app. The numbers on the top row work fine, and both sets of numeric keys work when I launch the app in windows.

Is this a known issue, is it just me, or is there a workaround?
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 23rd Jul 2022 22:43 Edited at: 23rd Jul 2022 22:48
i just discovered this myself ~ a month ago.

my post on discord: "interesting... it seems NumPad is the same as the ArrowKeys in HTML ScanCode-wise...".

i received no response to that but it appears they're the same as the arrowkeys (ie, 37-40) which corresponds to numpad 4,8,6 & 2 but don't recall what the others may have returned. (should be Home, End, Page Up/Down, insert, delete, etc.)

further testing should utilize GetRawLastKey() to see what the others might correspond to. if i get a chance, i'll put something together and report.

then, i believe it was raven who suggested using GetCharBuffer() for something related (distinguishing Upper/Lower keypresses) so i'll take a look at that, too, unless you/someone else beats me to it.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 23rd Jul 2022 23:50 Edited at: 24th Jul 2022 00:18
ok, taking a further look
Quote: "it appears they're the same as the arrowkeys"

...seems to apply when Shift is held down ON DESKTOP.

otherwise, see the HTML player source and this HTML Scancode tool for AGK (my manual testing results match the source).

don't ask my why it is this way but it's not good for the numeric entry you're looking for

you could map the keys to corresponding numbers, tho, and since there are so few, it wouldn't be much of a chore BUT there would be no way (that i know of) to determine whether or not the user pressed NumPad 4 OR LeftKey, for example, so those corresponding keys outside of the NumPad would be pretty useless.
Prime
1
Years of Service
User Offline
Joined: 15th Jun 2022
Location:
Posted: 24th Jul 2022 00:59
Quote: "you could map the keys to corresponding numbers, tho, and since there are so few, it wouldn't be much of a chore BUT there would be no way (that i know of) to determine whether or not the user pressed NumPad 4 OR LeftKey, for example, so those corresponding keys outside of the NumPad would be pretty useless."


I've been working on a module that handles editboxes, so maybe I could add an option to convert the raw scan codes into the expected numbers (only when an edit box is active).
Prime
1
Years of Service
User Offline
Joined: 15th Jun 2022
Location:
Posted: 24th Jul 2022 06:09 Edited at: 15th Aug 2022 05:12
In Windows, GetCharBuffer() returns 0 1 2 3 4 5 6 7 8 9 when the keypad keys are pressed, in Html5 nothing is returned
In Windows, GetRawLastKey() returns 96 97 98 99 100 101 102 103 104 105
In Html5, GetRawLastKey() returns 45 187 40 34 37 12 39 36 38 33 if numlock is active. If numlock is not active then the same keycodes are returned except 5 doesn't register


test program
Prime
1
Years of Service
User Offline
Joined: 15th Jun 2022
Location:
Posted: 24th Jul 2022 06:11
My solution is https://github.com/charlesgriffiths/agk-modules/tree/main/other/editboxes

If the appropriate variable is set, the numeric keypad keys (.0123456789) will work properly in an editbox, but the left and right arrow keys can't be used to move the cursor position because the keycodes overlap.
Prime
1
Years of Service
User Offline
Joined: 15th Jun 2022
Location:
Posted: 24th Jul 2022 06:13
Relevant code from module

Prime
1
Years of Service
User Offline
Joined: 15th Jun 2022
Location:
Posted: 24th Jul 2022 16:19
I posted in haste last night, and after more testing this morning I have updated the module. The html5 keypad behavior is the same on both classic and studio.

relevant code


Definitely not a perfect solution. You can use the mouse to position the editbox cursor but if you type numbers too fast, sometimes the cursor gets out of position. I found the cursor stays in place better when translating the keycode on GetRawKeyReleased() than on GetRawKeyPressed()

Login to post a reply

Server time is: 2024-04-27 00:39:44
Your offset time is: 2024-04-27 00:39:44