Overview
There are a number of scenarios in web development on touch devices where particular content may be obscured or behave differently when there is an onscreen keyboard present. This becomes particularly prevalent in the case of web text editors such as TinyMCE, when content that is being written by a user falls behind the onscreen keyboard. The only non-browser-implemented solutions thus far can be described as hacks at best, and tend to break on Operating System or browser updates.
With coordinates and sizes of onscreen onscreen keyboard components, a developer could create functionality that adapted to their presence.
#Proposed API (rough)
window.keyboard: Object attributes & functions:
-
window.keyboard.type : StringThe type of keyboard being used by the browser. It is proposed this returnsvirtualif there is an onscreen/virtual keyboard orphysicalif there is a hardware keyboard being used -
window.keyboard.visible : Boolean. Returnstrueif there is a virtual keyboard in an ‘up’ state (i.e. the keyboard can be seen, and is focused on an element). Returnsfalseif the keyboard cannot be seen, ornullif a physical keyboard is attached -
window.keyboard.getDimensions : function. When called, returns an array ofRectobjects (similar to the HTML canvas implementation), wheretopandleftare the coordinates of the keyboard fragment relative to the browser window - If no keyboard is visible, the coordinates of the last positions of the onscreen keyboard when it was shown are returned
- If a hardware keyboard is connected, an empty array (
[]) is returned - This function would cater for the use-case where there is an onscreen keyboard that has been split
window DOM events:
-
keyboardVisibilityChanged- Fired when the keyboard is shown or hidden. The event should contain reference to the keybard visibility variable (window.keyboard.visible) -
keyboardDimensionsChanged- Fired when the keyboard’s dimensions change- this may occur when a user switches keyboard types to a 3rd party keyboard, or when they split the keyboard into several segments). -
keyboardTypeChange- Fired when a hardware keyboard is connected or disconnected. The event should contain reference to the keyboard type (window.keyboard.type)
##About us We’re Ephox, developers of Textbox.io, and TinyMCE - The world’s most popular WYSIWYG HTML editor component.