View Full Version : Keyboard Press Detection Functionality
bnns
June 9th, 2009, 09:12 PM
I'm trying to get flash to recognize ctrl+z and ctrl+y for redo and undo functionality, though the detection is cut short when i hold the ctrl button first it prints out 17 but when i hit the z it just kills the capture. how would i trap all keys?
//17 ctrl,z 90
//17 ctrl,y 89
Lexxon
June 10th, 2009, 03:40 AM
The KeyboardEvent has a boolean property for ctrlKey. So, in your key down handler you can switch on the key code and check for z or y. Then inside there you can also check if ctrlKey is true.
function myHandler( e:KeyboardEvent ):void
{
switch ( e.keyCode )
{
case Keyboard.Y:
if ( ctrlKey )
{
// ctrl y pressed
}
case Keyboard.Z:
if ( ctrlKey )
{
// ctrl z pressed
}
}
}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.