Keyboard events not triggered
See original GitHub issueDescription of the problem:
I need to get the keyboard height when the keyboard will show (documented here : https://capacitor.ionicframework.com/docs/apis/keyboard).
All keyboard events is not triggered with method Keyboard.addListener('keyboardWillShow', ...)
but triggered with window.addEventListener('keyboardWillShow', ...)
.
Problem, window.addEventListener('keyboardWillShow', ...)
do not send that informations …
Affected platform
- Android
- iOS
- electron
- web
OS of the development machine
- Windows
- macOS
- linux
Other information:
- Application build with vuecli 3.2.3
Capacitor version: 1.0.0-beta.22
node version: v11.2.0
npm version: 6.9.0
CocoaPods version: 1.6.1
Steps to reproduce:
import { Plugins, Capacitor } from "@capacitor/core";
const { Keyboard } = Plugins;
Keyboard.addListener("keyboardWillShow", function(e) {
console.log(e); //not logged :(
});
window.addEventListener("keyboardWillShow", function(e) {
console.log(e); //log {"isTrusted":false}
});
Issue Analytics
- State:
- Created 4 years ago
- Comments:19 (8 by maintainers)
Top Results From Across the Web
Simple Keypress Event Not working for textbox - Stack Overflow
Hey you should try keypress event like this $("#howdy").keypress(function() { var keycode = (event.keyCode ? event.keyCode : event.which); ...
Read more >KeyboardEvent - Web APIs | MDN
A key that normally produces a character value has been pressed. This event was highly device-dependent and is obsolete. You should not use...
Read more >Key press event not triggering - Unreal Engine Forums
Background - I simply want to execute an event (called “Perform Event” here) when I press the “T” key - that calls an...
Read more >Keyboard: keydown and keyup - The Modern JavaScript Tutorial
The keydown events happens when a key is pressed down, and then keyup – when it's released. event.code and event.key. The key property...
Read more >Keyboard Events not triggering scripts in Perspective - Ignition
I am trying to put hotkeys on buttons by putting a script on the onKeyUp keyboard event, and triggering the script from the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@diadal I had the same problem, it seems like the native Capacitor
addListener
(or the code, which needs to be executed within it) runs outside the Angulars Zone. So we need to let the code run within the Angualars Zone again.I’m setting a variables value to true or false, when the keyboard will show or hide.
My (shortened) code:
Could this may be a general bug, when using Ionic 4 / 5 with Capactior(s native Bridge)?
Hope it helps.
Cheers Unkn0wn0x
@solojuve1897 as you are using the window event, be aware that on next release the
keyboardHeight
will be in the event directly instead of being on the event details, there won’t be details anymore. This is for better Cordova compatibility.But I would recommend using the new events that can be consumed from the plugin directly instead of using the window events.