Reputation: 1348
How do I get access to single keys using TouchScreenKeyboard? I tried
if (Input.GetKey(KeyCode.A))
UIActions.DebugText("The A Key was pressed!!");
but it is not returning anything. There seems to be only a minimal number of methods available to this class. What's the correct way to do this?
using UnityEngine;
public class FullKeyboardUserInput : MonoBehaviour
{
private TouchScreenKeyboard mobileKeys;
void Start()
{
mobileKeys = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default, false, false, false, true);
}
private void Update()
{
if (mobileKeys != null && mobileKeys.done)
{
GameManager.CurrentDriftName = mobileKeys.text;
UIActions.DebugText(GameManager.CurrentDriftName);
UIActions.NumKeyboardView(GameManager.instance.NumKeyboardUserInputView);
Destroy(gameObject);
}
if (Input.GetKey(KeyCode.A))
{
UIActions.DebugText("The A Key was pressed!!");
}
if (mobileKeys != null && mobileKeys.wasCanceled)
{
Destroy(gameObject);
}
}
}
Upvotes: 0
Views: 214
Reputation: 5035
Touch keyboard is not meant as a way to input keystrokes, its a way to input text - you can always use an InputField
Upvotes: 1