Certain keycodes don't register with IsKeyPressed (FIXED)

Started by monkey0506, Sat 17/10/2009 02:03:44

Previous topic - Next topic

monkey0506

I've only just noticed on my system that certain keys don't register with IsKeyPressed...ever. I know key combinations like Ctrl and Alt codes aren't supposed to register, but I'm finding that none of these do either:
[ eKeyOpenBracket
] eKeyCloseBracket
\ eKeyBackSlash
; eKeySemiColon
' eKeySingleQuote
, eKeyComma
. eKeyPeriod
/ eKeyForwardSlash
Is there a reason these keys don't register with IsKeyPressed? If it's possibly related I have this Logitech keyboard, though I doubt that's the case since on_key_press is still called normally.

The reason (specifically) why I'm asking is because it seems that you can't type an opening bracket into a textbox. I want to be able to do this. So I tried doing it manually by checking the raw state of the key and then appending the escaped character to the text...but it doesn't work!

Is there any way I can possibly type this character into a textbox?

Quote from: LOLIf you ask when the next version is coming out, you will be slapped silly with a moist trout.

Also when is the next version of AGS coming out already? :=

Edit by strazer:

Quote from: Pumaman on Sun 03/05/2009 15:34:47
Changes in 3.2 RC 2:
* Fixed IsKeyPressed not working with the following keys: [ ] \ ; ' , . /

Pumaman

Text boxes won't accept [ because it is the AGS New Line character, and you wouldn't be able to print it out again in a Display() or on a label since it would turn into a line break.

As for IsKeyPressed, you're right that it doesn't currently work with those keys -- looks like the mapping hasn't been set up. I'll fix that.

monkey0506

Quote from: Pumaman on Sat 17/10/2009 21:30:32Text boxes won't accept [ because it is the AGS New Line character

I understand that much. :P However I'm using the textbox for a non-standard purpose and I'd like to be able to type it in. I have nothing against having to code it manually, if it were possible. ;)

Quote from: Pumaman on Sat 17/10/2009 21:30:32As for IsKeyPressed, you're right that it doesn't currently work with those keys -- looks like the mapping hasn't been set up. I'll fix that.

Thanks Chris. If I could check the state of these keys I could then take care of scripting what I'm wanting to do.

Scarab

Well, just on the topic of IsKeyPressed and On_Key_Press....
I've noticed that when I'm applying them to my keyboard character movement, they behave differently.

On_Key_Press moves the character awkwardly and only seems to notice one button at a time, whereas IsKeyPressed works much more smoothly and seems to notice two at a time (and just executes them alternately)

I'd be really interested to know why this was.

Peace 8)
Scarab

Pumaman

Quote from: Scarab on Sun 18/10/2009 05:17:14
On_Key_Press moves the character awkwardly and only seems to notice one button at a time, whereas IsKeyPressed works much more smoothly and seems to notice two at a time (and just executes them alternately)

I'm not really sure what you mean.

on_key_press acts like any normal application. For example, if you open Notepad, press Q and then press W as well, you will only get W's and not Q's. This is standard behaviour.

IsKeyPressed can check multiple keys on the keyboard -- how many it can recognise at a time depends on your keyboard and the relative position of the keys.

Depending on what sort of character movement you want, you'll use one or other of the methods. For a Sierra-style press-to-start and press-to-stop walking system, on_key_press works perfectly. If you want the character to move while the key is held down, you'd use IsKeyPressed.

monkey0506

Also beyond that on_key_press is called with Ctrl-code combinations (AFAIK it isn't called for Alt-codes, right?) but IsKeyPressed will never return true for the key combinations (such as ASCII 1 = eKeycodeCtrlA). IsKeyPressed (as stated in the manual) checks the raw state of the key, ignoring all others (up to certain system-specific limitations as denoted by CJ above). Therefore combination keycodes don't make sense. But you could check the raw state of left/right Ctrl and another key.

These are all important differences to take note of when comparing IsKeyPressed and on_key_press.

SMF spam blocked by CleanTalk