 ;;************************************************
 
 (def $button ($ :#url_search_button))
+(def $text-field ($ :#url_search_text))
+
+(def enter-key 13)
+
+(defn- key-pressed 
+  "If keypressed = keycode then call func"
+  [key-code func event]
+    (when  (=  (.-keyCode event) key-code)
+      (func)))
+
+(defn return-key-pressed [f]
+  (partial key-pressed enter-key f))
 
 (defn- shorten-to [s max-length]
   (let [s-length (count s)]

           [:td (:tags %)]])
      data) ])

(defn button-handler []
  (let [query (jayq.core/val ($ :#url_search_text))
        parent (jayq.core/parent $button)]
    (-> (jayq.core/find parent :h2)
      (jayq.core/inner (str "Search results for '" query "'"))) 

                     (generate-rows data)))
       })))

(bind $button "click" mls-search)
(bind $text-field :keypress (return-key-pressed mls-search))
