From fc9bbe255fc1a3089b4316d03ec08f4415743a1f Mon Sep 17 00:00:00 2001 From: Zouhair Fouiguira Date: Fri, 27 Oct 2023 01:31:27 +0100 Subject: [PATCH] added OnkeyDown function for search --- src/App.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/App.js b/src/App.js index b37b487..fd7401f 100644 --- a/src/App.js +++ b/src/App.js @@ -22,6 +22,12 @@ const App = () => { setMovies(data.Search); }; + const handleSearch = (e) => { + if (e.key === "Enter") { + searchMovies(searchTerm); + } + }; + return (
@@ -31,7 +37,9 @@ const App = () => { setSearchTerm(e.target.value)} + onKeyDown={handleSearch} placeholder="Search for movies" + />