keycodes??

Mark Talluto userev at canelasoftware.com
Mon Nov 21 13:16:19 EST 2005


On Nov 18, 2005, at 1:27 PM, Phil Davis wrote:

> Sarah Reichelt wrote:
>> On 11/19/05, Charles Hartman <charles.hartman at conncoll.edu> wrote:
>>> Sometimes I need to use rawKeyDown handlers, which receive a keyCode
>>> parameter. Two questions: is there a table of these somewhere? and,
>>> are these cross-platform? (If I have to use two tables, and wrap
>>> everything in an "if platform" structure, I'm going to be very sad.)
>>>
>> Here is a link to a test stack I wrote to show you the key codes for
>> various keys: <http://www.troz.net/Rev/tutorials/KeyCoder.rev.gz>
>> I have always assumed they are cross-platform and don't remember
>> hearing of any problems.
>
>
> In my testing, I've seen platform differences in the keycodes of  
> some numeric keys (possibly uppercase?) and I think also the 10- 
> keypad keys (though I'm not certain about that one). I've never  
> compared non-numeric keycodes across platforms so I can't speak to  
> that.
>

I too have found that there are some difference between platforms.   
Here is a small snippet of code that I use to check for key entries:

on rawKeyDown which

     --CHECK FOR DECIMAL
     if which = 46 then pass rawkeyDown

     --CHECK FOR ARROW KEYS
     if which = 65361 or which = 65363  then pass rawkeyDown

     --CHECK FOR DELETE KEY PRESSES
     if which = 65288 then pass rawkeyDown

     --CHECK FOR FORWARD DELETE
     if which = 65535 then pass rawkeyDown

     --MAKE SURE INPUT IS A NUMBER (ABOVE LETTERS)
     if which >=48 and which <=57 then pass rawKeyDown

     --MAKE SURE INPUT IS A NUMBER (NUMERIC KEYPAD LINUX)
     if the platform is "linux" then
         if which >=65456 and which <=65465 then pass rawKeyDown
     end if

     --MAKE SURE INPUT IS A NUMBER (NUMERIC KEYPAD MAC & WIN)
     if the platform is "macos" or the platform is "win32" then
         if which >=65429 and which <=65439 then pass rawKeyDown
     end if
end rawKeyDown



Mark Talluto
-- 
CANELA Software
http://www.canelasoftware.com




More information about the use-livecode mailing list