I am actually doing a go / no go test in which a user have to press spacebar when he see a letter other then "F" and ignores when the letter F appears. But i am having a problem that if the user didn't press the spacebar on the letters other then F ,then it should be gone wrong but i am unable to code that thing
function respondToInput(event) {
if (event.code != undefined && event.code != 'Space') {
// Don't record non-spacebar presses
return;
} else if (textArea.textContent == 'F') {
if (event.code === 'Space') {
alert("You dont have to press the spacebar")
}
} else if (textArea.textContent != 'F') {
if (event.code != 'Space') {
alert("You have to press the spacebar")
}
}
}