Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70435

Handle alert action when keyboard enter key is hit

$
0
0

@shepard wrote:

If I create an alert, how can I handle the Save button when the keyboard ‘Go’ button is pressed?

this.alertCtrl.create({
            header: 'YourAddress',
            message: 'What is your address?",
            inputs: [
                {
                    name: 'address',
                    type: 'text',
                    value: this.address,
                    placeholder: 'Address'
                }
            ],
            buttons: [
                {
                    text: 'Cancel',
                    handler: data => {
                        console.log('Cancel clicked');
                    }
                },
                {
                    text: 'Save',
                    handler: data => {
                        console.log('SAVE DATA: ' + data);
                    }
                }
            ]
        }).then(alert => alert.present());
@HostListener('document:keydown.enter', ['$event']) onKeydownHandler(evt: KeyboardEvent) {
        console.log('enter key hit: How do I handle the alert as if the Save button was pressed? ');
    }

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70435

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>