I think you should use the “keyup” event. The “keydown” event triggers when the key is down and therefore the value of the key is submitted into the input only after the function is called.
Why is every one using jQ to get the values? e is already a jQ event/object so you can do just e.currentTarget.value - the .search is an input element right?
And the reason it is not working is simple jQ call does not return the string but the whole object within this making the call chainable, so you have to simply chain the call and do !template.$('.search').val(), but don’t do that, you can save some CPU time by utilizing e.
I would do it on focus and pull the value from the search box. Have an if statement that checks what is in the value. If its blank then hide. else show search box