I posted about this a while back and didn't get much of a response. Am hoping someone might have discovered a workaround as this bug is a bit of a show-stopper for the project I am working on.

I am trying to trap whether the Caps Lock key is down at any given moment, not toggled, but down. On Windows, the Caps Lock key results in the onKeyUp and onKeyDown events being generated whenever the key is pressed or released. On the Mac the same is not true. The onKeyDown event is only generated when the Caps Lock key is untoggled and the user presses the key. The onKeyUp event is only generated when the Caps Lock key is toggled and the user presses the key. What makes it more frustrating is that the isDown(Key.CAPSLOCK) code on the Mac returns true when the key is toggled not whether the key is in fact down. It makes accurately tracking the up and down states of the Caps Lock key on the Mac impossible.

The project I am working on requires knowing the state of the Caps Lock key. Again, it works as expected on Windows, but not on the Mac. You can see this in action here:

http://www.aleph-1.com/keyboard/

You can donwload the FLA here:

http://www.aleph-1.com/keyboard/keyboard.fla

The code is as follows:

fscommand('trapallkeys',true);

var frames:Number = 0;
var keyListener:Object = new Object();

keyListener.onKeyUp = function() {
        if(Key.getCode() != Key.CAPSLOCK) return;
        _txt.text += 'frame ' + frames + ': Caps Lock was released.' + newline;
        _txt.scroll = _txt.maxscroll;
}

keyListener.onKeyDown = function() {
        if(Key.getCode() != Key.CAPSLOCK) return;
        _txt.text += 'frame ' + frames + ': Caps Lock was pressed.' + newline;
        _txt.scroll = _txt.maxscroll;
}

Key.addListener(keyListener);

onEnterFrame = function () {
        frames++;
        if (Key.isDown(Key.CAPSLOCK)) {
                _txt.text += 'frame ' + frames + ': Caps Lock is down.' + 
newline;
                _txt.scroll = _txt.maxscroll;
        }
};

Please, if anyone has had any luck in successfully trapping the up / down state of the caps lock key on the Mac, please let me know.

Cheers.

Daniel Barber
aleph1
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to