Repository navigation
Open
Labels
concerns: device independenceProposal is hardware- or OS-specific, in a way that may risk the device independence of the Webfrom: MicrosoftProposed, edited, or co-edited by Microsoft.topic: device apisSpec relates to device APIs: access to device-specific hardware, sensors, and interfacestopic: editingSpec relates to text editingtopic: web apisSpec relates to web APIs (entry points for script)venue: W3C Web Editing WG
Description
Request for position on an emerging web specification
Information about the spec
- Spec Title: VirtualKeyboard API
- Spec URL: https://www.w3.org/TR/virtual-keyboard/
- GitHub repository: https://github.com/w3c/virtual-keyboard/
- Issue Tracker: https://github.com/w3c/virtual-keyboard/issues
- Explainer: https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/VirtualKeyboardAPI/explainer.md
Design reviews and vendor positions
- TAG Design Review: VirtualKeyboard API - show/hide policy w3ctag/design-reviews#498 (comment)
- Mozilla standards-positions issue: Virtual Keyboard Control mozilla/standards-positions#531
Bugs tracking this feature
- WebKit Bugzilla: https://bugs.webkit.org/show_bug.cgi?id=230225
- Radar: rdar://83154723
Anything else we need to know
Implemented in Chromium: https://web.dev/virtualkeyboard/
Reacted by Westbrook Johnson, Austin Armstrong, cybai, Sean Perkins, Liam DeBeasi, Mike Hartington, Steven Sherry, Alex Moore, Bruno Stasse, Miguel Sánchez Villafán and 16 more
Reacted by leeyucha, Igor Ryzhov, Peyton, sandstrom, Apolo, Cameron Pak and Kirill Zyusko
Metadata
Metadata
Assignees
Labels
concerns: device independenceProposal is hardware- or OS-specific, in a way that may risk the device independence of the Webfrom: MicrosoftProposed, edited, or co-edited by Microsoft.topic: device apisSpec relates to device APIs: access to device-specific hardware, sensors, and interfacestopic: editingSpec relates to text editingtopic: web apisSpec relates to web APIs (entry points for script)venue: W3C Web Editing WG
Type
Projects
- StatusShow more project fieldsNeeds position
Activity
othermaciej commentedon Jun 29, 2022
bramus commentedon Jun 29, 2022
litherum commentedon Jun 30, 2022
I have concerns about
navigator.virtualKeyboard.show()for 2 reasons:tomayac commentedon Jun 30, 2022
FWIW, the inability to control how the virtual keyboard appears was brought up as a top pain point by Telegram in a technical post on WebKit issues:
othermaciej commentedon Jun 30, 2022
If scroll-to-center behavior is bad for their app, there's probably a much simpler feature that could meet that specific need - this API seems too complex to be the obvious way to address this problem.
snianu commentedon Jun 30, 2022
VK would only appear if the focus is inside an editable element and there is a sticky user activation. This API lets the web author control the show/hide behavior of the VK only when the
virtualKeyboardPolicyis inmanualmode. Default behavior isauto. The discussion in the TAG review thread has more details about the behavior of this API. Based on feedback from @rniwa & @whsieh, I thought we had positive support from Apple?whsieh commentedon Jun 30, 2022
My understanding is that we will only allow web authors to programmatically show the keyboard using the Virtual Keyboard API in scenarios where authors are already capable of programmatically showing the keyboard by focusing an editable element.
(At one point, I recall giving feedback during TPAC that
show()and possibly alsohide()should return a promise, that rejects if the UA prefers to not show the keyboard, for the reasons Myles noted earlier).liamdebeasi commentedon Jun 30, 2022
This API is something that would be very valuable for developers using Ionic. Our use case is ensuring that inputs that scroll on non-body elements are not covered by the keyboard.
The default scroll-to-center behavior in Safari is not ideal because it causes other content to be shifted offscreen. We wrote a "scroll assist" utility to prevent the browser from shifting content off screen while ensuring that the input is not covered by the keyboard: https://github.com/ionic-team/ionic-framework/blob/main/core/src/utils/input-shims/hacks/scroll-assist.ts.
Below is an example of the default behavior as well as the custom Ionic behavior:
default-safari.mp4
custom-ionic.mp4
With the default behavior, observe that the header and part of the content are shifted offscreen. With the custom behavior, observe that neither the header nor the content is shifted offscreen.
The downside of this custom approach is we need to estimate the height of the keyboard. This can cause inputs to still be hidden by particularly tall keyboards. It can also cause inputs to be scrolled more than they need to be.
Being able to know a) the geometry of the keyboard and b) when the geometry of the keyboard changes would significantly improve the user experience of apps built with Ionic. We do not have a big need for programmatically showing/hiding the keyboard at the moment, but I do see how that functionality could be considered confusing by some.
edit: We do also make use of the Virtual Viewport API to get a better idea of the keyboard geometry. Our main problem with that is the event fires after the keyboard is fully open. As a result, we have to wait ~500ms before we can scroll the input into view. This gives the impression of a slow/unresponsive application.
brunostasse commentedon Jul 1, 2022
Apart from preventing the scroll-to-center and the layout viewport shrinking behaviours, which is useful in itself as shown by @liamdebeasi example, this API also provides information about the size of the virtual keyboard. It is provided both through the JS API, and through CSS environment variables (
keyboard-inset-*).Such information is useful to properly scroll into view in-flow inputs as suggested above, but also for element which are supposed to be fixed right above the VK. This is very common in chat interfaces, where the text input is usually at the bottom of the viewport by default, and moves up with the keyboard as it opens. It is also common for note taking apps, where you often have a toolbar positioned right above the keyboard. Without this information, there is currently no way to produce these kind of interfaces.
As pointed out above, it appears that in Chrome's implementation the
ongeometrychangeevent might be fired too late (I haven't tested myself). It would indeed be much better for the event allowing to detect change in the geometry to be sent as the VK starts appearing, and not after it has fully appeared. This is what the specification seems to be recommending, so this might just be an implementation issue.Virtual Keyboard API specification
3 remaining items
jamie-pate commentedon Apr 18, 2023
This api would also be useful for webassembly projects that afaik currently have no supported way to control the virtual keyboard?
HolgerJeromin commentedon Apr 19, 2023
I want to prevent my own keyboard when there is a native keyboard.
So having
navigator.virtualKeyboard.boundingRectand thegeometrychangeevent would be great for some use cases even without havingshowandhide.woody-li commentedon Aug 7, 2024
user-0a commentedon Jan 24, 2025
sandstrom commentedon Oct 9, 2025
ApoloApps commentedon Jun 8, 2026
I was working in the https://github.com/JetBrains/compose-multiplatform for Web implementation of WindowInsets.ime and stumbled across this api. The web APIs are a mess of supported and unsupported and it makes implmentation of full canvas canvas almost impossible or just difficult to implement consistently across OSs and browsers. This API would greatly simplify the code in our side and make it more maintainable long-term. See weird workarounds). There are definitely valid usecases and I would like for the WebKit team to at least consider to implement it. Thanks!
rniwa commentedon Jun 8, 2026
FWIW, https://developer.mozilla.org/en-US/docs/Web/API/VisualViewport does get updated when a software keyboard comes up.
ApoloApps commentedon Jun 8, 2026
VisualViewport has some bugs that prevents the devs to get the correct viewport size (it is impossible to get the correct size of the full viewport including system bars, which makes canvas apps look weird) and it would introduce more problems than it solves (at least with the current shape of the API). Also, VisualViewport is resized when 2-pinch zooming and again another vector to take into account.
Edit: and then fact that we need to get the actual values via workarounds just to get them, it makes a pretty bad DX :)
cameronapak commentedon Jul 24, 2026
+1 I want this feature and am willing to be a sounding board for feedback
TingPing commentedon Nov 20, 2026
I've spent some time looking into real world usage of this and I'd like to propose implementing a subset of the API: drop
show(),hide()andvirtualkeyboardpolicy, and consider only the read-only geometry part:boundingRect,geometrychange,env(keyboard-inset-*)andoverlaysContent.These seem like the most valuable portions of the API allowing sites to consistently know where the keyboard is.
WebKit recently enabled
interactive-widget(319118@main). Withinteractive-widget=resizes-content, the page resizes above the keyboard, and together with VisualViewport that covers the common layouts. It doesn't cover the cases where the keyboard doesn't resize the viewport, or where something else does:overlays-content: nothing resizes, so the page can't tell what the keyboard covers.The keyboard's geometry answers all of these directly.
If WebKit is open to this subset, I can prototype it.