def add_key_binding(
        self,
        *keys: Keys | str,
        filter: FilterOrBool = True,
        eager: FilterOrBool = False,
        is_global: FilterOrBool = False,
        save_before: Callable[[KeyPressEvent], bool] = (lambda e: True),
        record_in_macro: FilterOrBool = True,
    ) -> Callable[[_T_kh], _T_kh]:
        """
        Shortcut for adding new key bindings.
        (Mostly useful for a config.py file, that receives
        a PythonInput/Repl instance as input.)

        All arguments are identical to prompt_toolkit's `KeyBindings.add`.

        ::

            @python_input.add_key_binding(Keys.ControlX, filter=...)
            def handler(event):
                ...
        """
        return self.extra_key_bindings.add(
            *keys,
            filter=filter,
            eager=eager,
            is_global=is_global,
            save_before=save_before,
            record_in_macro=record_in_macro,
        )

        Shortcut for adding new key bindings.
        (Mostly useful for a config.py file, that receives
        a PythonInput/Repl instance as input.)

        All arguments are identical to prompt_toolkit's `KeyBindings.add`.

        ::

            @python_input.add_key_binding(Keys.ControlX, filter=...)
            def handler(event):
                ...
        
src/ptpython/python_input.py