Stop browser moving on playing

hello folks,

ive been looking for this. but can see anything. but when i play a online game made with HAXE/OPENFL, if its not fullscreen mode, it actually moves the screen while pressing the arrow keys.

should i just change the keys? or is there a way to stop the window from moving with some coding black magic?

many thanks

Is your browser window moving? May be you pressed some of OS shortcut keys? If so - you need to change keys in your app.

aye its moving, but the keys are just up/down for now. which i understand why its happenenig.

but wouldnt OPENFL have a ‘ignore window moving on game focus’ type thing?
changing keys is one way, but im sure there is an ignore window move on game focus. i just dont know it :wink:

Wouldn’t that be the browser’s operation actually? I don’t know how you would control the browser to not move, since that’s outside of the control of the browser content.

Looked it up, seems possible:

But this would be in the HTML5 target template, I suppose. In your equivalent of here:

1 Like

great, thanks for the link.

well. i was hoping that there would be something the could stop the browser to stop shifting if you press keys, as long as the HTML game is in focus - say clicked on to say ‘you are now focussed’

ill have a look see. its either that or just change the controls :wink:
but i dont actually type in QWERTY, im DVORAK, so its hugely different to set keys, unless i make a key mapper thing :wink:

thanks again both of you :wink:

I was afraid of this

This was recently commented, try uncommenting it for your project. It interfered with the HTML5 text input code that was recently written, I’m not 100% sure how to best handle this

1 Like

oooh brilliant.
ill try it later on. i did change the key layouts to FRONG for something else, since its 4 player had to use the qwerty layout best :wink:

but will give it a go when i can. thanks

The preventdefault stuff is uncommented in the current version of lime. Is there a way to selectively disable it without manually editing the file after each compile? I’m trying to embed it beside a codemirror instance, and it’s gobbling my valuable keypresses :’( (I haven’t fully worked out the even gobbling/bubbling order in my html file yet, so there’s still a chance I can fix this nicely myself).

The latest version should have this disabled – I’m still not sure what we should do to avoid page scrolling on arrow and space, but I do think it’s inappropriate to block all these events as you may be blending with any number of native HTML elements that rely on these events. Have you tried updating?


Oh, I updated and that seemed to deal with it. Woo. Thanks :slight_smile:

My take on the general problem is that stuff like not scrolling in response to input is a property of the layout rather than the canvas/generated openfl stuff, and should be embedded either directly in the generated html file, or included as a separate js file to the main one haxe generates.

That way if people use their own layouts it won’t automatically not scroll, but if they look at the generated one they can see pretty easily how to go about disabling scrolling.

Oh, that’s a good idea, updating the default templates to disable that behavior. I wonder how you handle the keyboard event and preventDefault, without preventing the standard Lime behavior from working. I suppose someone has probably figured this out somewhere :slight_smile:

1 Like