I changed this to a keyup event handler instead of keydown as suggested, and I think it works better that way from my testing. I also added the short-circuiting you suggested so it ignores keyups that are not from the backspace, enter, or delete key.