ASCII codes and the number keypad

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dsquance
Posts: 40
Joined: Mon Jan 18, 2010 2:47 am

ASCII codes and the number keypad

Post 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?
Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: ASCII codes and the number keypad

Post 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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
mmiele
Posts: 55
Joined: Sun Jan 21, 2007 1:25 pm

Re: ASCII codes and the number keypad

Post 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
dsquance
Posts: 40
Joined: Mon Jan 18, 2010 2:47 am

Re: ASCII codes and the number keypad

Post 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
dsquance
Posts: 40
Joined: Mon Jan 18, 2010 2:47 am

Re: ASCII codes and the number keypad

Post 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
dsquance
Posts: 40
Joined: Mon Jan 18, 2010 2:47 am

Re: ASCII codes and the number keypad

Post by dsquance »

I should have tried a few things before the last posting. I have a working solution. Thanks for this great resource.

Dave
Post Reply