Answers for "how to focus on next input on press enter key in react"

2

capture enter button react input

const Enter = () => {
  	const handle = () => console.log('Enter pressed');
  
	return <input type="text" onKeyDown={e => e.key === 'Enter' && handle} />;
};
Posted by: Guest on February-11-2021
2

on enter key press react js

useEffect(() => {
    const listener = event => {
      if (event.code === "Enter" || event.code === "NumpadEnter") {
        console.log("Enter key was pressed. Run your function.");
        event.preventDefault();
        // callMyFunction();
      }
    };
    document.addEventListener("keydown", listener);
    return () => {
      document.removeEventListener("keydown", listener);
    };
  }, []);
Posted by: Guest on June-09-2021

Code answers related to "how to focus on next input on press enter key in react"

Code answers related to "Javascript"

Browse Popular Code Answers by Language