How to print something if a user types in a specific word in the inputfield?

Hey guys,
Basically I don’t how to state this but here it goes.
In the input field how to recognize a list of commands so when the user types in a command it print a sentences e.g. I type in “New Game” and it print something or switch to a new game scene

Sorry if this don’t make sense

Here is a simple script I made. Let me know if you don’t understand everything. I am comparing strings, but I think that regular expressions would be better. Especially if you want to play with command arguments.

using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;

public class CommandPrompt : MonoBehaviour
    // Drag & Drop the inputfield in the inspector
    public InputField inputfield;
    private Dictionary<string, System.Action<string,string>> commands;

    protected void Awake()
        commands = new Dictionary<string, System.Action<string,string>>();

        // Add the commands you want to recognise along with the functions to call
        commands.Add( "new game", OnNewGameTyped );
        commands.Add( "hello", OnHelloTyped );

        // Listen when the inputfield is validated
        inputfield.onEndEdit.AddListener( OnEndEdit );

    private void OnEndEdit( string input )
        // Only consider onEndEdit if the Submit button has been pressed
        if ( !Input.GetButtonDown( "Submit" ) )

        bool commandFound = false;

        // Find the command
        foreach ( var item in commands )
            if ( item.Key.ToLower().StartsWith( input.ToLower() ) )
                commandFound = true;
                item.Value( item.Key, input );

        // Do something if the command has not been found
        if ( !commandFound )
            Debug.Log( "No command found" );

        // Clear the input field (if you want)
        inputfield.text = "";

    private void OnNewGameTyped( string command, string input )
        Debug.Log( "Starting new game" );
        UnityEngine.SceneManagement.SceneManager.LoadScene( 1 );

    private void OnHelloTyped( string command, string input )
        Debug.Log( "Hello my friend !" );