def func_on_enter(func):
    """
    Register the `func` as a callback reacting only to ENTER.

    Note:
        This function doesn't bind the key to the element, just creates sort of
        filter, which ignores all other events.
    """
    def function_after_enter_pressed(ev):
        ev.stopPropagation()

        # if the key was `enter` ..
        if ev.keyCode == 13:
            func(ev)

    return function_after_enter_pressed
def func_on_enter ( func ) : def function_after_enter_pressed ( ev ) : ev . stopPropagation ( ) if ev . keyCode == 13 : func ( ev ) return function_after_enter_pressed
Register the `func` as a callback reacting only to ENTER.

    Note:
        This function doesn't bind the key to the element, just creates sort of
        filter, which ignores all other events.