Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keypress Scripting Question

Status
Not open for further replies.

janeekg

Programmer
Joined
Jun 13, 2002
Messages
4
Location
US
Question:

I am creating (in Flash) an online environment to mimic Microsoft Word. The end user will be performing operations such as copying text. One of the ways to copy text is Crt/C.

I know the script for this is:

if (Key.isDown(17) and Key.isDown(67))
action here

BUT...when coded in this way, the user has to push ctrl and c at the exact same time or it won't work. Anyone know a way to first hit ctrl, and while holding that down, hit c - much like keyboard shortcuts really work?
Does it have something to do with the "while" action?

Thank you in advance!
Help is GREATLY appreciated :-)
 
Put this action on a movieClip with the enterFrame event handler:

onClipEvent (enterFrame) {
if (Key.isDown(17) {
if (Key.isDown(67) {
// action here
}
}
}

That way, when CTRL is pressed, nothing happens, but because the script is executed once every frame, it continuously checks to see if the C key has been pressed too.
 
That worked...Thank you very much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top