I have a search-form that searches some text for me. When I type in the input box I have to manually press a button for it to search. Is there a way for me to hit enter
on the keyboard and have that search, as well as the button?
(defn search-form
[]
[:div
[:p "What are you searching for? "
[:input
{:type :text
:name :search
:on-change #(swap! fields assoc :search (-> % .-target .-value))
:value (:search @fields)}]]
[:input
{:type :submit
:value :Search
:on-click #(do
(search-function (:search @fields)))}]
[@search-results]])
This is the code I currently have. As you can see, to call the search-function
I have to click on the button. I would like to be able to press enter
and also have the ability to press the button and both will call search-function
Any help would be much appreciated. Thanks