W3C home > Mailing lists > Public > whatwg@whatwg.org > June 2010

[whatwg] Is there a way to stop scrolling when pressing directional arrows?

From: Bjartur Thorlacius <svartman95@gmail.com>
Date: Tue, 15 Jun 2010 22:09:10 +0000
Message-ID: <AANLkTimQWMyE_DBPVJ3S-yGm1bPdhZX9gc_wxjnuE4mv@mail.gmail.com>
On 6/14/10, Kornel Lesinski <kornel at geekhood.net> wrote:
> On Mon, 14 Jun 2010 20:38:07 +0100, Carlos Andr?s Sol?s
> <csolisr at gmail.com> wrote:
>
>> Hello! I've been noticing a problem in many HTML5 test apps, very
>> especially games. When the directional arrow buttons are pressed, the
>> screen scrolls.
>> This is a problem that, as far as I know, Flash had solved by changing
>> the focus of the application to the app. Is this doable in HTML5?
>
> Yes. It's possible already ? page just has to return false from keypress
> handler:
>
> window.onkeypress = function(){return false}
>
> That's just one line that, unfortunately, many web-based games forget to
> include.
>
The bad thing about the Flash behaviour is that it seems to completely steal
keyboard focus if programs even listen to onkeypress. window.onkeydown
should return false only when the application is actually going to use that
keypress.

-- 
kv,
  - Bjartur
Received on Tuesday, 15 June 2010 15:09:10 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:24 UTC