Change to keydown event so that the first character always appears