diff --git a/src/viewer.js b/src/viewer.js index 1a7490d0..7e20ec85 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -300,6 +300,8 @@ $.Viewer = function( options ) { style.left = "0px"; style.resize = "none"; }( this.keyboardCommandArea.style )); + // Set read-only - hides keyboard on mobile devices, still allows input. + this.keyboardCommandArea.readOnly = true; this.container.insertBefore( this.canvas, this.container.firstChild ); this.container.insertBefore( this.keyboardCommandArea, this.container.firstChild ); @@ -2310,6 +2312,13 @@ function onBlur(){ function onCanvasClick( event ) { var gestureSettings; + var haveKeyboardFocus = document.activeElement == this.keyboardCommandArea; + + // If we don't have keyboard focus, request it. + if ( !haveKeyboardFocus ) { + this.keyboardCommandArea.focus(); + } + if ( !event.preventDefaultAction && this.viewport && event.quick ) { gestureSettings = this.gestureSettingsByDeviceType( event.pointerType ); if ( gestureSettings.clickToZoom ) {