Skip to content

Commit 55a83c3

Browse files
committed
Fix keyboard
Fixes #166
1 parent cd8d91b commit 55a83c3

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

squeak.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -747,10 +747,7 @@ function createSqueakDisplay(canvas, options) {
747747
input.setAttribute("autocapitalize", "off");
748748
input.setAttribute("spellcheck", "false");
749749
input.style.position = "absolute";
750-
input.style.width = "0";
751-
input.style.height = "0";
752-
input.style.opacity = "0";
753-
input.style.pointerEvents = "none";
750+
input.style.left = "-1000px";
754751
canvas.parentElement.appendChild(input);
755752
// touch-keyboard buttons
756753
if ('ontouchstart' in document) {
@@ -761,7 +758,7 @@ function createSqueakDisplay(canvas, options) {
761758
canvas.parentElement.appendChild(keyboardButton);
762759
keyboardButton.onmousedown = function(evt) {
763760
// show on-screen keyboard
764-
input.focus();
761+
input.focus({ preventScroll: true });
765762
evt.preventDefault();
766763
}
767764
keyboardButton.ontouchstart = keyboardButton.onmousedown;
@@ -795,8 +792,8 @@ function createSqueakDisplay(canvas, options) {
795792
cmdButton.ontouchcancel = cmdButton.ontouchend;
796793
} else {
797794
// keep focus on input field
798-
input.onblur = function() { input.focus(); };
799-
input.focus();
795+
input.onblur = function() { input.focus({ preventScroll: true }); };
796+
input.focus({ preventScroll: true });
800797
}
801798
display.isMac = navigator.userAgent.includes("Mac");
802799
// emulate keypress events

0 commit comments

Comments
 (0)