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.

Newcomers AppGameKit Corner / How to detect keystate?

Author
Message
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 27th Jan 2016 08:45
I noticed that there are guides for keystates in the help files.

But, how do we detect keys that were not listed?

I tried to find out what keystate F4 and ALT key was assigned to, but there are no command that detect what keys are being pressed.

So, how do we get keystate number for keys that are not listed in the help file (such as ALT and F4 keys)?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 27th Jan 2016 08:51
Google Keycodes and you'll find numerous maps, like...

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 27th Jan 2016 09:04 Edited at: 27th Jan 2016 09:12
You can see the keycode for the last pressed key with this:

GetRawLastKey()

EDIT:

This code does not work, it seems as if no more key will be detected when holding down the ALT key :-(

13/0
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 27th Jan 2016 10:05
Thanks. GetRawLastKey() worked!
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 27th Jan 2016 11:26
Did you get ALT+F4 working?
13/0
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 27th Jan 2016 12:40
Something weird happened. It is as you said.

GetRawLastKey() detect F4 as 115, and ALT as 18

When ALT key is pressed WHILE the F4 key are being held down, then it works.

But,

If the F4 key are being pressed WHILE the ALT key are being held down, then only the F4 keys are being registered. ALT key is not in this case.
It deosnt matter what keys i wrote firstt on the code, but the result is the same.

A bug I suppose.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 27th Jan 2016 13:41
Quote: "If the F4 key are being pressed WHILE the ALT key are being held down, then only the F4 keys are being registered. ALT key is not in this case.
"


In this case, F4 is the last key pressed. It can only hold one value at a time.

You need getRawKeyState() which works on multiple key presses at the same time, I just tested.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 27th Jan 2016 14:49
You mean, like this?
I used it to end the program


IF GetRawKeyState( 18 ) > 0 AND GetRawKeyState( 115 ) > 0
END
ENDIF


If the F4 pressed first, then it works.
IF ALT pressed first, then it doesn't

getRawKeyState() can detect multiple key presses, but somehow it doesn't detect F4 key if ALT key is pressed first.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 27th Jan 2016 20:36
I understand the issue now, and actually, it's worse than you think!
If you try the following Key sequence, the F4 key state gets stuck at 1, even after you stop pressing:

F4 DOWN
ALT DOWN
F4 UP
ALT UP






- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 28th Jan 2016 05:11
Is this bug worth reporting?

Where do we properly report bugs anyway?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 28th Jan 2016 09:12 Edited at: 28th Jan 2016 09:13
Yes, I would suggest reporting it. Create a new thread starting the title with BUG:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt

Login to post a reply

Server time is: 2024-04-19 20:17:25
Your offset time is: 2024-04-19 20:17:25