WebAPI/BrowserAPI/KeyboardEvent

From MozillaWiki
< WebAPI‎ | BrowserAPI
Revision as of 08:42, 6 May 2014 by Gyeh (talk | contribs) (Created page with "== Dispatch KeyboardEvent across BrowserElements == This is a proposal to enable applications to handle/override the behavior of certain KeyboardEvent. There are four scenar...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Dispatch KeyboardEvent across BrowserElements

This is a proposal to enable applications to handle/override the behavior of certain KeyboardEvent.

There are four scenarios which should be fulfilled:

Scenario Description Example Keys
SYSTEM-ONLY For keys which should be handled by mozbrowser embedder iframe only. 'Power', 'VolumeUp', 'VolumeDown', 'VolumeMute', 'DisplaySwap'
SYSTEM-FIRST For keys which can be handled by mozbrowser embedder iframe first and can also be handled by mozbrowser embedded iframe then. 'Info', 'Settings'
APP-ONLY For keys which should be handled by mozbrowser embedded iframe only. 'ColorF0Red', 'ColorF1Green', 'ColorF2Yellow', 'ColorF3Blue', 'ColorF4Grey'
APP-FIRST For keys which keys can be handled by mozbrowser embedded iframe first and can also be handled by mozbrowser embedder iframe then. 'Info', 'Settings'


Note that some keys could be either SYSTEM-FIRST or APP-FIRST. The behavior is decided by the author of applications.

Four new events are proposed:

  • mozbrowserbeforekeydown
  • mozbrowserkeydown
  • mozbrowserbeforekeyup
  • mozbrowserkeyup
Concept diagram

When a key is pressed down, the event sequence would be:

  1. 'mozbrowserbeforekeydown' is dispatched to mozbrowser-embedder iframe
  2. 'keydown' is dispatched to mozbrowser-embedded iframe
  3. 'mozbrowserkeydown' is dispatched to mozbrowser-embedder iframe

Similarly, when a key is released, the event sequence would be:

  1. 'mozbrowserbeforekeyup' is dispatched to mozbrowser-embedder iframe
  2. 'keyup' is dispatched to mozbrowser-embedded iframe
  3. 'mozbrowserkeyup' is dispatched to mozbrowser-embedder iframe