Skip to main content
buksori
Inspiring
June 9, 2020
Question

What can I use for ((keyPress "<Space>")) ?

  • June 9, 2020
  • 1 reply
  • 421 views

===========================
<<Action Script 1.0>>
on (release, keyPress "<Space>") {
gotoAndStop(10);
tellTarget ("_root") {
play();
}
}

===========================

In Animate 2020, What can I use for ((keyPress "<Space>")) ?
===========================

 

var _this = this;
_this.stop();

var _this = this;

_this.PlayMovie.on('click', function(){

_this.gotoAndPlay(50);
});

===========

In this script, what can I add for keyPress(space bar) event?

I hope anyone will help me for this problem.

 

This topic has been closed for replies.

1 reply

JoãoCésar17023019
Community Expert
Community Expert
June 9, 2020

Hi.

 

You need to add an event listner of the keydown type and check for the space key. Like this:

var _this = this;

_this.stop();

window.addEventListener("keydown", function(e)
{
	if (e.code === "Space")
		_this.gotoAndPlay(50);
});

 

I hope this helps.

 

 

Regards,

JC

buksori
buksoriAuthor
Inspiring
June 12, 2020

Thank you for your help.

=========================
var _this = this;
_this.gotoPlayBtn.on('click', function(){
_this.gotoAndPlay(216);
});
=========================

When I want to use both "mouse click" and "keydown", how can I insert "keydown" in the above script?

I hope you will help me again.
Thank you.

 

Regards,

buksori