WebAPI/InputMethod API with hardware keyboard
< WebAPI
Jump to navigation
Jump to search
Meta bug: bug 929365.
Idea
The previous iteration of InputMethod API (See WebAPI/KeboardIME) enables the keyboard apps to interact with the targeted input field. We would like it to handle the connected hardware keyboard as well.
Prerequisite
The critical keys (POWER, HOME and so on) need to be handled by system app first.
Proposal
This proposal is based on WebAPI/BrowserAPI/KeyboardEvent.
- The blue lines are the current behavior. [line (1)]
- This proposal is about adding keyboard app into the chain right before the event target (the active app).
- In mozbrowser*before*keyXXX phase, Gecko dispatches the key events to keyboard app prior to deliver it to the event target if and only if keyboard app is active. [line (2)]
- If keyboard app wants to handle certain keys, it should cancel the events by calling "preventDefault" (or something else, we'll talk about it later).
- If keyboard app doesn't cancel the events, Gecko will then dispatch it to the event target as usual. [line (3)]
- If keyboard app cancels the events, it should be regarded the same as cancelled by the event target and follow the same rules defined in WebAPI/BrowserAPI/KeyboardEvent.
TBD
- Internal API
- How to determine whether keyboard app is active or not?
- How to dispatch the key events to keyboard app
- External API
- How to register/unregister a listener to handle the key events in keyboard app? (inputContext.addEventListener() ?)
- How many categories of the events are needed? (keydown and keyup should be required. How about keypress?)
- What is the event name? (keyXXX or mozbrowserbeforekeyXXX may be not appropriate since keyboard app is never focued)
Limitation
If an input field is embedded in system app (i.e. there are only two levels: shell.html and system app) and gets the focus, we need to dispatch the events prior to system app (event target). Therefore, it will violate the prerequisite.
Solution for now:
Make these APIs be certified apps only and trust the build-in keyboard apps.
Questions
- Is it possible to detect the current hardware keyboard type? (e.g. qwerty or T9)