rewrite js as a jquery fn extend. enter key works properly. less error prone. less bugs.