Page 1 of 1

ASCII codes and the number keypad

Posted: Sat Apr 30, 2011 5:08 am
by dsquance
I have a Mac laptop with an external (Apple) keyboard and want to use rawkeydown so that a minus sign will initiate an action in a specific field. The ASCII code is 45 in the main part of the keyboard, which works but it doesn't on the number pad. The latter is critical in this instance. Anyone know how to get this to work?

Re: ASCII codes and the number keypad

Posted: Sat Apr 30, 2011 11:15 am
by Mark
dsquance,

What exactly "doesn't" on the numerical pad?

Do you have a numlock key?

I have a setup exactly equal to yours (but the keyboard might be a different model). The - key gives - in the keyDown handler and 65453 in t he rawKeyDown handler.

Kind regards,

Mark

Re: ASCII codes and the number keypad

Posted: Sat Apr 30, 2011 11:36 am
by mmiele
Using

Code: Select all

on keyDown theKey
   put chartonum(theKey) into me
end keyDown
as a field script, it gives me "45" for both keys.

while using

Code: Select all

on rawKeyDown theKey
   put theKey into me
end rawKeyDown
gives me "45" for the left "minus" key and "65453" for the "minus" key on the num pad.

The numlock key seems to have no effect.

I'm not sure it could be useful for you, anyway...

Kind regards,

Mario

Re: ASCII codes and the number keypad

Posted: Sat Apr 30, 2011 3:52 pm
by dsquance
The number 64543 is what I needed, and works. Thanks to both of you who replied. I didn't remember there was a way to reverse my steps to get the number generated. There's nothing under ASCII in the help that mentions this.

Dave

Re: ASCII codes and the number keypad

Posted: Sat Apr 30, 2011 4:12 pm
by dsquance
Further to this, I'm trying to use this with an enterinfield handler, so that when a number is typed and then the minus sign is pressed, the negative of the number typed will be entered. Any suggestions?
Dave

Re: ASCII codes and the number keypad

Posted: Sat Apr 30, 2011 6:42 pm
by dsquance
I should have tried a few things before the last posting. I have a working solution. Thanks for this great resource.

Dave