• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Quick Time Event how to assign two keys simultaneously instead of one

Explorer ,
Jan 21, 2019 Jan 21, 2019

Copy link to clipboard

Copied

Hello, masters!

Heres a nice trivial question which is a lot to me still.

I talked about how to create a Quick Time Event system which is to press a key on time to move on. Now I want to know how to press TWO keys in order to advance, possibly even 3! Thanks ❤️

import flash.events.KeyboardEvent; 

import flash.ui.Keyboard; 

 

function keyDownHandler(e:KeyboardEvent):void 

     if (currentScene.name == "Scene 1") 

     { 

          if (e.keyCode == Keyboard.E) 

               gotoAndStop(1, "Scene 2"); 

     }

Help!.jpg

Views

1.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 22, 2019 Jan 22, 2019

Copy link to clipboard

Copied

Aside using the mobile gestures, this kind of thing would fall back to AS3 traditionally tracking one key at a time. One event will fire per key but not at the same time. Here is an older post where Ned mentions a way how to handle something like this:

Recognizing multiple key presses in As3

It'd be useful to handle this within a Timer so here is some example code that initialized a timer but did not fully use it, but it should get you more than started:

actionscript 3 - Multiple key press conditionals in AS3

Both are doing essentially the same thing except if you set the Timer to a short amount of milliseconds as they did (100), and both keys are found to be pressed that close together, it's a bit more realistic to expect they were pressed together.

You'll want to clear anything you were looking for either when the Timer end fires or on KEY_UP so you are ready to trap the next. Here's the API just for reference:

KeyboardEvent - Adobe ActionScript® 3 (AS3 ) API Reference

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 22, 2019 Jan 22, 2019

Copy link to clipboard

Copied

LATEST

Thanks, I'll look into to this.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines