code: def on_key_press(self, keydef, mode='force'):
          
          def register(fun):
              @self.key_binding(keydef, mode)
              @wraps(fun)
              def wrapper(state='p-', name=None):
                  if state[0] in ('d', 'p'):
                      fun()
              return wrapper
          return register
docs: Function decorator to register a simplified key binding. The callback is called whenever the key given is
          *pressed*.
  
          To unregister the callback function, you can call its ``unregister_mpv_key_bindings`` attribute::
  
              player = mpv.MPV()
              @player.on_key_press('Q')
              def binding():
                  print('blep')
  
              binding.unregister_mpv_key_bindings()
  
          WARNING: For a single keydef only a single callback/command can be registered at the same time. If you register
          a binding multiple times older bindings will be overwritten and there is a possibility of references leaking. So
          don't do that.
  
          The BIG FAT WARNING regarding untrusted keydefs from the key_binding method applies here as well.