You can publish code within code tags. See Some XHTML is allowed when you post here.
Do not known what is happen. If the ESC key work, that mean that maybe you bind your own Enter key, or there is another event that prevent Enter key. Simply to test. Try first it without any special binding or functions like onclick and etc.