Key events stops working

Key events stops working

Hi,
I have this code in a website I'm making:
  1. $(document).ready(
  2. function () {
  3. $('body').keyup(function(event){
  4.                         console.log(event.which);
  5. if(event.which == 46){
  6. $('#delete').click();
  7. }
  8. });
  9.                 ( more bindings )
  10. });
But the event isn't working all the time. It stops working after I change to another window and come back to the browser window.

Someone has any idea of what I can try to get it work all the time?

Thanks,
João Proença