$("#cor_name").keyup(function(*!*eventObject*/!*){ changed_name = $("#cor_name").val(); if (*!*event*/!*.keyCode == 13) { alert(changed_name); } });