Attach keyup and keydown events to text field