views:

27

answers:

1

Is there any cross-platform-safe method for dealing with keyboard shortcuts in Flash?

For example, on my Mac, pressing ctrl+f results in a KeyboardEvent where the keyCode is 6, but on Windows, the keyCode is 70.

A: 

The keyCode 70 is 'F' without the CTRL. I would guess the browser is taking priority over that combination since it's commonly used for searching the page you're on and that's why you're getting the different codes.

6 must be the command button I think, but I might be wrong, it's not included here: http://www.adobe.com/livedocs/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001136.html

You could try tracking them seperately, listening for Keyboard.CONTROL (const from flash.ui.keyboard) and your '6' and when have that and you receive the 70 then you have your CTRL+F.

If your flash is destined for a browser I would use a combination that's not in use already though.

Ben
Sorry — that's not true. The escape codes (`^D`, `^R`, `^C`, etc) are *always* sent from <kbd>ctrl</kdb> on the Mac, so this has nothing to do with the example I used being `^F`. And I'm specifically trying to avoid tracking them separately — ideally I'd like to say "listen for ctrl+d", and it will take care of making sure that works.
David Wolever
I could be wrong about the browser taking priority and the command code - 6 isn't on their keyCode table which is odd.I don't think you have any choice about tracking them separately, there's no built in keyCodes that define CTRL+F or any other combination.
Ben