I have developed a mobile app that allows users to search for specific items. Currently, when the user presses Space, it creates a tag. However, I want the tag to be created when the user presses go/search/enter on the mobile keyboard instead of spacebar.
Currently, the code below functions by creating the tag when it encounters a " ". This needs to be modified because some items consist of two words like Chia Seeds.
constructor(public keyboard: Keyboard, public formBuilder: FormBuilder, public navCtrl: NavController, public navParams: NavParams, public apiAuthentication: ApiAuthentication, private http: Http) {
this.tags = [];
this.myForm = this.formBuilder.group({
tags: ['']
});
this.myForm.get('tags')
.valueChanges
.subscribe((value: string) => {
if(value.indexOf(' ') > -1) {
let newTag = value.split(' ')[0];
console.log(newTag);
if(newTag) {
this.tags.push(newTag);
this.myForm.get('tags').setValue('');
}
this.searchRecipeDB(this.tags);
}
});
}
I am unsure about how to make the go/enter button function on mobile devices, so any help with that would be much appreciated.
Thank you,