How to stop space bar/down arrow from scrolling?

Discussion and feedback on Construct 2

Post » Fri Dec 02, 2011 2:40 am

(In Firefox, at least)

Isn't that kind of a huge problem with playing games in a browser? It won't stop scrolling down while I'm playing, which is... bad. Any solution for this?
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Fri Dec 02, 2011 5:37 am

When i checked the Space Blaster Example game, there was a code there preventing it.
At least thats what the code comment said.

Just make a Event called "Keyboard: On Space Pressed" and have nothing in the Action section.

This is what the game code comment said, quoted.
"This event is intentionally empty, it simply stops the browser scrolling down when you press spacebar (Construct 2 prevents browser shortcuts if any key press event exists for it)."
B
11
S
2
G
2
Posts: 18
Reputation: 1,913

Post » Fri Dec 02, 2011 7:12 am

Hmm... I DO have actions for those keys, though. I'll try throwing in addition blank ones and see if it helps anyway. Thanks for the response!
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Fri Dec 02, 2011 2:21 pm

The arcade should stop this by itself, but @maldrok is right, for other games not hosted on the arcade you simply need empty 'On key pressed' events and it will block the browser's default action (which is scrolling for spacebar). You have to add blank events because it's designed to not affect the rest of the browser or page unless it really has to - it might be annoying for some people if every C2 game blocked spacebar/arrow key scrolling.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sat Dec 03, 2011 12:07 am

I find that frustrating sometimes also. isn't there any easier way to do this?
it is because html5 doesn't lock keys to be in a closed window, right?
B
20
S
5
G
4
Posts: 61
Reputation: 3,165

Post » Sat Dec 03, 2011 12:21 am

Is adding two or three empty events not easy enough?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sun Dec 04, 2011 6:36 am

^ lol
B
47
S
10
G
6
Posts: 455
Reputation: 8,326


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 9 guests