I think it is sufficient to check e.which (according to this page: http://api.jquery.com/keyup/ and http://api.jquery.com/event.which/).