- Home /
Mobile Keyboard event calls
I am wanting to play animations when the buttons on the keyboards are pressed. I want this is only for mobile devices for both iOS and android. I want this to be done on "Done" , "Cancel" and "Return". How can i do this?
Answer by Grish_tad · Nov 13, 2017 at 07:04 PM
You can try this. I think "Done" and "Return" is same thing
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class keyboardtest : MonoBehaviour {
private TouchScreenKeyboard keyboard;
string text= "";
// Use this for initialization
public void Start () {
keyboard = TouchScreenKeyboard.Open(text, TouchScreenKeyboardType.Default);
}
public void GetKeyboardActivity()
{
if (keyboard != null)
{
if (keyboard.done)
{
text = keyboard.text;
}
if (keyboard.wasCanceled)
{
text = keyboard.text;
}
}
}
}
For more details you can read this.
this is causing problems with the input fields text, when you remove focus from inputfield1 and then come back to it , this will remove the text entered in inputfield1. For this case i have used input triggers Event Triggers (Select and DeSelect) but you can also use OnEditEnd on the InputField component.
Answer by sumit47 · Aug 28, 2019 at 08:36 PM
how to detect when user click on clear button ?
Your answer
Follow this Question
Related Questions
Does Unity support different pixel densities? 1 Answer
Back button does nothing when keyboard is open (Android, Pixel 3 XL, unity 2019.2.7f2) 1 Answer
How to make floating mobile keyboard in mobile game ? 0 Answers
How to make my object bounce off the screen bounds? 1 Answer
Prevent mouse input trough GUI button on mobile game Unity 2019.4 1 Answer