New Input System: How to collect an input string

Eg say I want a person to type in their name followed by enter how to handle that?

At the moment I’m doing something like
Which is obviously terrible, whats the accepted way

void HandleTextInput( InputAction.CallbackContext context )
    {
        if (Keyboard.current.anyKey.isPressed)
        {
            foreach (var key in Keyboard.current.allKeys)
            {
                if (key.isPressed)
                {
                    string keyName = key.name;

                    bool isShiftPressed = Keyboard.current.shiftKey.isPressed;

                    if ((keyName.Length == 1 && char.IsLetterOrDigit( keyName[0] )) || keyName == "minus" || keyName == "enter" )
                    {
                        if ( key.name == "enter" )
                        {
                            textInputAction.Disable();
                            App.instance.leaderboard.players_name = App.instance.leaderboard.players_Displayname;
                            App.instance.leaderboard.UpdatePlayersName();
                            App.instance.leaderboard.GetScores();
                            return;
                        }
                        if (key.name == "minus")
                        {
                            keyName = "_";
                        }

                        if (isShiftPressed && char.IsLetter( keyName[0] ))
                        {
                            keyName = keyName.ToUpper();
                        }

                        if ( App.instance.leaderboard.started_typing_name == false )
                        {
                            App.instance.leaderboard.started_typing_name = true;
                            App.instance.leaderboard.players_Displayname = "";
                        }
                        App.instance.leaderboard.players_Displayname += keyName;
                    }
                }
            }
        }
    }

You should not handle text input this way. This will break on different keyboard layouts and for different languages. Generally, you want the operating system to handle text input, doing it yourself will lead to a lot of frustration for users.

Check the documentation for the Input System, specifically the section on Text input under Keyboard support. Also check the following section on IME, which is required for supporting e.g. Chinese, Korean, Japanese or Vietnamese.