code: def on_key_press(self, event):
          
          # Zooming with the keyboard.
          key = event.key
          if event.modifiers:
              return
  
          # Pan.
          if self.enable_keyboard_pan and key in self._arrows:
              self._pan_keyboard(key)
  
          # Zoom.
          if key in self._pm:
              self._zoom_keyboard(key)
  
          # Reset with 'R'.
          if key == 'R':
              self.reset()
docs: Pan and zoom with the keyboard.