// Update is called once per frame void Update() { text.text = state.Text(); foreach (KeyValuePair <KeyCode, State> action in state.Actions()) { if (Input.GetKeyDown(action.Key)) { state = action.Value; } } }