Oliver,

Thanks for responding. I had come up with a far uglier solution that did 
what I needed (for US keyboards) and fixed the problems you described. 
So I will replace my code with what you have supplied.

Thanks again,
Daniel.


> On Mar 3, 2006, at 1:59 PM, Daniel Pool wrote:
>
>> I have an object that captures keystrokes via an onkeydown event  
>> method.
>>
>>> From here I can use LZKeys and the keycode passed to the method to  
>>> tell
>>
>> what keys were pressed. What is the correct way to map this to the
>> character that was pressed? I want to take into account the shift key,
>> the caps lock key, and potentially any special characters returned by
>> other key combos such as the alt key on the mac. Also would be nice to
>> handle different responses for different keyboards and languages.
>> Essentially I want to be able to get the character that a field would
>> insert if it received the same keydown event.
>>
>> Currently I am doing something like the following:
>>
>> <method event='onkeydown' args'aKeyCode'>
>>     var charPressed = String.fromCharCode(aKeyCode);
>>     // do some stuff
>> </method>
>>
>> but that isn't really right.
>
>
> I've put the code that I use for this at http://osteele.com/sources/ 
> openlaszlo/laszlo-utils.js.  It defines a function  
> LzKeys.fromEventCode() that does what you want for U.S. keyboards, if  
> you don't use the 'option' key.
>
> This patches the bugs in LzKeys.keyCodes ('<>' are missing; all the  
> shifted numbers are off by one), and adds translation tables to  
> handle SHIFT for non-alphabetic characters.


_______________________________________________
Laszlo-user mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-user

Reply via email to