Problem with HTML5 in iFrame and arrow keys

Subscribe to Problem with HTML5 in iFrame and arrow keys 10 posts

avatar for gdacas gdacas 8 posts
Flag Post

Hello!
I’m testing a HTML5 game (made in Construct 2) wich I uploaded as an iFrame and everything is working fine but the key system. The player moves the character with right and left arrow keys and jump with the up arrow key. The problem is that when I press the up arrow to jump, not only the character jumps but the hole site scrolls ups too.

Is there any solution or will I have to change the input jump key in my game?

Thanks for the attention people!

 
avatar for Draco18s Draco18s 6860 posts
Flag Post
//CSS
body {
   overflow:hidden;
}
 
avatar for gdacas gdacas 8 posts
Flag Post

Nope, that unfrotunatly does not work.

Anyone have any idea of how to resolve that?

 
avatar for Draco18s Draco18s 6860 posts
Flag Post

Replace “body” with whatever your frame is. The goal is to remove the scroll bars.

 
avatar for gdacas gdacas 8 posts
Flag Post

Draco18s, it works perfetcly for the scrollers of the game screen, thanks a lot for that!
But does not work with the scrollers of the entire page in the browser.
Every time I press the up arrow the hero jumps and the entire page goes up, like I were heading up in the content of the hole site.

 
avatar for DrYoshiyahu DrYoshiyahu 678 posts
Flag Post

Try a different control scheme? (WASD)

 
avatar for gdacas gdacas 8 posts
Flag Post

Yep, I had to change the control scheme, unfortunatly.
The game is here: http://www.kongregate.com/games/gdacas/the-world-is-ending

 
avatar for gdacas gdacas 8 posts
Flag Post

Still, in some point, when I press the space bar, the game loses focus.

Anyone knows what could I do to set the focus at every tick to the game? Or some other solution?

Thanks in advance fellow developers!

 
avatar for gdacas gdacas 8 posts
Flag Post

I fixed it.
The thing is that I was listening for the “Key is down”. When I tried to listen to “Key is pressed” the focus stayed in the game.

 
avatar for AMD_Paulius_J AMD_Paulius_J 110 posts
Flag Post

What a nice game! It really refreshed me this morning 5/5.