code: def add_custom_binding(self, key_name, command, arguments, needs_prefix=False):
          
          assert isinstance(key_name, six.text_type)
          assert isinstance(command, six.text_type)
          assert isinstance(arguments, list)
  
          # Unbind previous key.
          self.remove_custom_binding(key_name, needs_prefix=needs_prefix)
  
          # Translate the pymux key name into a prompt_toolkit key sequence.
          # (Can raise ValueError.)
          keys_sequence = pymux_key_to_prompt_toolkit_key_sequence(key_name)
  
          # Create handler and add to Registry.
          if needs_prefix:
              filter = HasPrefix(self.pymux)
          else:
              filter = ~HasPrefix(self.pymux)
  
          filter = filter & ~(WaitsForConfirmation(self.pymux) |
                              has_focus(COMMAND) | has_focus(PROMPT))
  
          def key_handler(event):
              " The actual key handler. "
              call_command_handler(command, self.pymux, arguments)
              self.pymux.get_client_state().has_prefix = False
  
          self.custom_key_bindings.add(*keys_sequence, filter=filter)(key_handler)
  
          # Store key in `custom_bindings` in order to be able to call
          # "unbind-key" later on.
          k = (needs_prefix, key_name)
          self.custom_bindings[k] = CustomBinding(key_handler, command, arguments)
docs: Add custom binding (for the "bind-key" command.)
          Raises ValueError if the give `key_name` is an invalid name.
  
          :param key_name: Pymux key name, for instance "C-a" or "M-x".