Input System callback performed twice

performed is triggered twice when I press an arrow key. one at button down, one at button up. why ?
This is the default UI action map in default asset.

    private void OnEnable()
    {
        InputSystem.actions.FindAction("Navigate").performed += Log;
    }

    private void OnDisable()
    {
        InputSystem.actions.FindAction("Navigate").performed -= Log;
    }

    void Log(InputAction.CallbackContext ctx)
    {
        Debug.Log(ctx.phase); // show 2 Performed
    }

May I see the InputActionAsset editor with the setup for the Navigate action? I am especially interested in the bindings and interactions that are attached to the action.

The Pass Through setup is problematic - this should be set to Button for keys in order to retrieve the right amount of events at the right time.

yes from what I understand, pass through create a performed event for each value difference.

But switching to value or button throw a warning that this is not expected and may not work correctly.

so it’s a bit weird. what if I want to subscribe to button down on navigate with this default asset ?

Those are the actions used by the Event System. They’re set up specifically to work with the Event System and are not necessarily intended to be used for other input, which might need a different configuration of these actions.

What are you trying to do?

Instead of directly using the Input System, if you want to integrate with the Event System, using the Event System instead of the Input System directly would be better, to e.g. check if there’s actually a navigation that can be performed on the current Selectable.

If you just want to react to some inputs irrespective of the Event System, you could just duplicate the action and then you can configure it freely.

I have a scrollview with its content made up of many settings as children and sub-children ui element. I want the scrollview to focus on the current selected element to keep it visible by adjusting the scroll value (scrollbar) when a new element is selected.

Actually It’s working with performed event (button up and down) with a conditional check if the selected element is a deep child of content. But the hold functionality is missing. If the player keep scrolling, I would like an easy way to detect the repeat input from Event System. (a repeat callback functionality from the input system is missing ?)

You’re really using information that’s way too low-level for your purpose.

I’m not sure if you’re using uGUI or UI Toolkit but e.g. for uGUI, you’d better use ISelectHandler or by tracking EventSystem.currentSelectedGameObject.

Otherwise, you’ll run into edge cases of how input is processed in the Event System and will have to replicate them in your own logic. E.g. the hold functionality you mentioned, which you’d have to re-implement and make sure you’re using the same delay/repeat timings.

1 Like