Skip to content

fix keyboard input in mobile browsers #1317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

SuperMaxusa
Copy link
Contributor

Fixes #262 (and probably #1212) by adding input event handler, tested in Chrome and Firefox on Android.

@copy
Copy link
Owner

copy commented May 1, 2025

Thanks, this looks like a good approach!

We could use some help with testing. I've deployed this version here: https://copy.sh/v86-staging/

Testing on ios: Both versions open the OS keyboard and work fine. The only differences seems to be that the new version scrolls to the top of the screen. This probably needs an e.preventDefault().

It would be nice if we could find a way to "downgrade" to using the input event gracefully, instead of checking the user agent. Maybe something like this:

keydown:
if(e.code === "Unspecified")
{
    // let the input handler run
    return;
}
// call preventDefault here to prevent the input handler
// or, if that is not robust, disable the input handler until the next keyup event

@SuperMaxusa
Copy link
Contributor Author

SuperMaxusa commented May 1, 2025

The only differences seems to be that the new version scrolls to the top of the screen.

Same on Android, it because phone_keyboard always spawns at the top of page and browser focuses on it while typing.

v86/src/browser/main.js

Lines 2590 to 2592 in a3840e3

// stop mobile browser from scrolling into view when the keyboard is shown
phone_keyboard.style.top = document.body.scrollTop + 100 + "px";
phone_keyboard.style.left = document.body.scrollLeft + 100 + "px";

v86-phonekb

EDIT: I sketched out a few ideas on how to fix it:

@SuperMaxusa
Copy link
Contributor Author

I pushed a fix to prevent screen scrolling and tried to fix keyboard and mouse in graphical OSes (on copy.sh/v86 it always opens the keyboard).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

android keyboard not working
2 participants