enter & keypress
https://stackoverflow.com/questions/905222/enter-key-press-event-in-javascript
https://stackoverflow.com/questions/16011312/execute-function-on-enter-key
https://www.w3schools.com/jsref/event_onkeypress.asp
https://memorynotfound.com/detect-enter-keypress-javascript-jquery/
inputClickEnter() {
let that = this;
let input = document.querySelector(`[data-input="search"]`);
input.addEventListener(`keypress`, (e) => {
console.log(`press enter key`, e);
if (e.which === 13 || e.keyCode === 13) {
that.getSearchData();
}
});
},
demo
inputClickEnter() {
let that = this;
let input = document.querySelector(`[data-input="search"]`);
input.addEventListener(`keypress`, (e) => {
console.log(`press enter key`, e);
if (e.which === 13 || e.keyCode === 13 || e.key === "Enter" || e.charCode === 13 || e.code === "Enter") {
that.getSearchData();
}
// if (e.which === 13 || e.keyCode === 13 || e.key === "Enter") {
// that.getSearchData();
// }
// if (e.which === 13 || e.charCode === 13 || e.code === "Enter") {
// that.getSearchData();
// }
});
},