code: def on_key(self, event):
          
  
          # If paste is running and Esc is pressed then we need to abort
  
          if event.GetKeyCode() == wx.WXK_ESCAPE and \
             self.pasting or self.grid.actions.saving:
              self.need_abort = True
  
          event.Skip()
docs: Sets abort if pasting and if escape is pressed