First of all, let me tell you my purpose. If the entry is blank, a divin will appear, but when something is typed the divin will be "display: none".
I want this to happen, but as shown in the video, I tell me not to press the delete key if the input value is blank and it works, 3 words and "I deleted the number 8" only appeared 3 times on the screen recording. Strangely, when the delete key is pressed slowly, the divim successfully "display: block", but when I hold my finger without pulling it (I tried it in the key press event) it doesn't do that. You can check all the codes on my github account. Full code: https://github.com/BerkayAkgurgen/Film-ProjectAPI/tree/main
Screen Record
// key event
searchInput.addEventListener('keydown', e => {
let control = false
if (e.which == 8 && searchInput.value.trim() == "") {
control = true
} else {
control = false
}
if (control) {
e.preventDefault()
return
}
console.log(e.which);
})
where I check empty input
if (inputValue == "" || !isNaN(inputValue)) {
ui.clearInput()
ui.returnBack()
} else {
filmRequest.getDatas(inputValue)
.then(data => {
ui.displayResults(data)
ui.resultUI()
})
}
// Style Changes
returnBack() {
this.mostPopulerHeader.style.display = "block"
this.topParents.style.display = "grid"
this.resultHeader.style.display = "none"
this.resultParent.style.display = "none"
}
resultUI() {
this.mostPopulerHeader.style.display = "none"
this.topParents.style.display = "none"
this.resultHeader.style.display = "block"
this.resultParent.style.display = "grid"
}