Updated to use event.which and .focusout shorthand method

event.which seems to be the way to go according to recent documentation.