Use keydown instead of keyup events, and stop event propagation.
Prevent default event action when pressing return to prevent newline from being inserted.