Problem with iFrame and arrow keys

4 posts

Flag Post

I’m testing a game 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 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!

Flag Post

Here is a better place to ask for help.

Flag Post

If Kongregate gives you access to the main document within the iFrame (which is HIGHLY unlikely), you can use something like the following:

var ar=new Array(33,34,35,36,37,38,39,40);

$(document).keydown(function(e) {
var key = e.which;
//if(key==35 || key == 36 || key == 37 || key == 39)
if($.inArray(key,ar) > -1) {
return false;
return true;

Flag Post

Thanks guys!