apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.15k stars 987 forks source link

App is not listening any keyboard input until the screen is tapped #1132

Closed nekobungi closed 1 year ago

nekobungi commented 2 years ago

Bug Report

Problem

Just after launch, the app will not accept any keyboard input, no matter what keybord event listeners you have added. However, if you tap or click the screen even once, all keybord events will start to be listening.

This may not be a problem for many apps that are primarily made for the iPhone, since they mainly works with touch screens.

However, in recent years, as Apple has started to feature more keyboards for the iPad, and iOS apps are now running on Macintosh, non-touch screen based operation has become more and more important.

Unfortunately, the need to tap the screen with this bug makes it currently impossible to create an app such as utility app operated using only the keyboard, or gaming app playing via keyboard.

What is expected to happen?

Listen to keyboard input right after app launch.

What does actually happen?

Keyboard input will not start listening until you tap or click the screen.

Information

Command or Code

You can reproduce the problem by following these steps:

  1. Create an empty HelloWorld project, add iOS platform
  2. Adding to anywhere in js/index.js a keybord input event listner, such as this:
    document.addEventListener("keydown", event => {
    document.body.innerHTML = event.keyCode;
    });
  3. Build and launch the app on an iPad with keyborad connected, a Mac, or a simulator
  4. Hit any key on your keyboard
  5. Tap or click anywhere in the app sreen
  6. Hit any key on your keyboard again

Environment, Platform, Device

Version information

Checklist

dpogue commented 1 year ago

I've marked this issue as stale because it's been over a year with no further comments. If this is still an issue in the latest cordova-ios version and an up-to-date iOS version, please let us know. Otherwise, this issue will be closed.

nekobungi commented 1 year ago

@dpogue Yes, it is still an issue in the latest cordova-ios with the latest environments, such as: