Highlighted

Using both "mouse click" and "keydown",

Explorer ,
Jun 15, 2020

Copy link to clipboard

Copied

=========================
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(ex:space key)" in the above script?

I hope you will help me again.
Thank you.

 

Regards,

buksori

Views

78

Likes

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

Using both "mouse click" and "keydown",

Explorer ,
Jun 15, 2020

Copy link to clipboard

Copied

=========================
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(ex:space key)" in the above script?

I hope you will help me again.
Thank you.

 

Regards,

buksori

Views

79

Likes

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
Jun 15, 2020 0
Adobe Community Professional ,
Jun 15, 2020

Copy link to clipboard

Copied

Hi.

 

This should work:

var _this = this;

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

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

 

Please let us know.

 

Regards,

JC

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

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
Reply
Loading...
Jun 15, 2020 1
buksori LATEST
Explorer ,
Jun 15, 2020

Copy link to clipboard

Copied

Thank you for your help. Your reply is very helpful to me.

 

I tried to use "Space" and "Enter" key. They worked well.

But I wonder why other keys(ex: p key, s key , alt key, ctrl key and etc) except Space and Enter key don't work.

I hope you will help me again...

 

I appreciate for your help again.

Likes

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
Reply
Loading...
Jun 15, 2020 0