def add_custom_binding(self, key_name, command, arguments, needs_prefix=False):
assert isinstance(key_name, six.text_type)<EOL>assert isinstance(command, six.text_type)<EOL>assert isinstance(arguments, list)<EOL>self.remove_custom_binding(key_name, needs_prefix=needs_prefix)<EOL>keys_sequence = pymux_key_to_prompt_toolkit_key_sequence(key_name)<EOL>if needs_prefix:<EOL><INDENT>filter = HasPrefix(self.pymux)<EOL><DEDENT>else:<EOL><INDENT>filter = ~HasPrefix(self.pymux)<EOL><DEDENT>filter = filter & ~(WaitsForConfirmation(self.pymux) |<EOL>has_focus(COMMAND) | has_focus(PROMPT))<EOL>def key_handler(event):<EOL><INDENT>"<STR_LIT>"<EOL>call_command_handler(command, self.pymux, arguments)<EOL>self.pymux.get_client_state().has_prefix = False<EOL><DEDENT>self.custom_key_bindings.add(*keys_sequence, filter=filter)(key_handler)<EOL>k = (needs_prefix, key_name)<EOL>self.custom_bindings[k] = CustomBinding(key_handler, command, arguments)<EOL>
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".