ionic-team / cordova-plugin-ionic-keyboard

Keyboard Plugin for Cordova
Other
193 stars 178 forks source link

Is it possible to preventDefault within the keyboardWillShow event #78

Closed john-doherty closed 5 years ago

john-doherty commented 5 years ago

Is there a way to cancel the keyboardWillShow event to stop the keyboard from showing in certain conditions?

window.addEventListener('keyboardWillShow', (event) => {
    if (document.activeElement && document.activeElement.id === 'whateverEl') {
        return false;
    }
});
jcesarmobile commented 5 years ago

No, it's not possible. What you can do is set the field to readonly="true", so it still sends the click event but prevents from writing, or trigger blur on the field or calling hide (but it might still show the keyboard for a brief moment)