I'm trying to get the events generated by a button that I assume is specific to brazilian keyboard, the "Próximo" button (same as "Next"). Some devices I work with have this button, and I can't listen to the events generated by them, if they emit any events at all.
The app I use is developed with Ionic and Angular. The purpose of listening to this button is as follows: I have an array of objects and a page that displays an object's data. The user can modify the object data through some inputs. The user can navigate between these inputs through the "Next" button. When the user is at the last input and presses the button, the next object is loaded.
This event and function already work with the "Enter", "Next" and "Go" button, that exist on some devices and as far as I've noticed are visual variations of the same button. The only problem I have is with this "Próximo" button that does not generate any event, therefore it does not activate the function. I've already tried to listen for the event of this button using different methods, which I will list below.
Note: test()
is a function that only logs the key event
Keydown, keypress and keyup property in ion-input, also with variants as keyup.enter
<ion-input (keypress)="test($event)"></ion-input>
(ionInput) property on ion-input
<ion-input (ionInput)="test($event)"></ion-input>
Listener with pure JavaScript (tested with keydown, keypress and keyup and their variants)
ionViewDidLoad() {
document.addEventListener('keydown', (key) => {this.test(key)} );
}
Angular's HostListener (tested with keydown, keypress and keyup and their variants)
// I also tried with `'window:keydown'`
@HostListener('keydown', ['$event']) test(event) {
console.log(event);
}
References:
- HostListener do Angular
- (keypress) event in ionic 4 not triggering
- keypress event is not working in ionic 2 Android
- How to handle "Go"/"Enter" keyboard button Ionic2
- keypress event not firing with enter key in angular 2
- Keydown Event to save locally using javascript
- Check if a key is down?
- Keydown event for 'Next'
- Listen for keypress / keydown event locally in react router component
- How to get LOCALIZED character on keypress?
- on e.keycode == 9 (tab), add 12 spaces, and prevent default behavior
- How to get Next button on android softkeyboard in place of Go Button in phonegap
- KeyboardEvent.keyCode deprecated. What does this mean in practice?
- Angular 2 HostListener keypress detect escape key?
- How to trigger a Tab when user presses Enter
- Eventos do Ion-Input