Is there a way for my function to be triggered by either clicking a button or pressing the spacebar?
I have managed to make it work partially, but it's not quite right.
This is the function in question:
const showText = () => {
const x = ToughSpellings.toString();
console.log(x);
}
These are the actions for the button and spacebar:
<input type="text" id="one" onKeyUp={showText} />
<button onClick={showText}>Show Next Letter</button>
I'm struggling to figure out how to incorporate the onKeyUp event without using an input field. How can I make this function work when the user is just browsing the website?