Skip to content

Commit

Permalink
added OnkeyDown function for search
Browse files Browse the repository at this point in the history
  • Loading branch information
ZOUHAIRFGRA committed Oct 27, 2023
1 parent de15ffd commit fc9bbe2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ const App = () => {
setMovies(data.Search);
};

const handleSearch = (e) => {
if (e.key === "Enter") {
searchMovies(searchTerm);
}
};

return (
<Router>
<div className="app">
Expand All @@ -31,7 +37,9 @@ const App = () => {
<input
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
onKeyDown={handleSearch}
placeholder="Search for movies"

/>
<img
src={SearchIcon}
Expand Down

0 comments on commit fc9bbe2

Please sign in to comment.