- Home /
 
Using the IOS Keyboard
Hello everyone. I know this is a very basic question, and I don't mean to have you guys write code for me, but I cannot figure out how the IOS keyboards work. In all the tutorials and articles in the unity scripting manual, I can not decipher how to use keyboards, or even copy and paste the code in. I want to know how to open and hide the keyboard. Thanks! If someone could show me the c# method, I would appreciate it. I am a newbie.
Answer by chetanisinanand · Aug 13, 2015 at 06:21 AM
Hi , you might want to look into TouchScreenKeyboard
I believe TouchScreenKeyboard.Open is what you are looking for. Look into the following code i got from scripting reference:
 using UnityEngine;
 using System.Collections;
 
 public class ExampleClass : MonoBehaviour {
     public string stringToEdit = "Hello World";
     private TouchScreenKeyboard keyboard;
 
     // Opens native keyboard
     void OnGUI() {
         stringToEdit = GUI.TextField(new Rect(10, 10, 200, 30), stringToEdit, 30);
 
         if(GUI.Button (new Rect(10, 50, 200, 100), "Default"))
         {
             keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default);
         }
         if(GUI.Button (new Rect(10, 150, 200, 100), "ASCIICapable"))
         {
             keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.ASCIICapable);
         }
         if(GUI.Button (new Rect(10, 250, 200, 100), "Numbers and Punctuation"))
         {
             keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.NumbersAndPunctuation);
         }
         if(GUI.Button (new Rect(10, 350, 200, 100), "URL"))
         {
             keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.URL);    
         }
         if(GUI.Button (new Rect(10, 450, 200, 100), "NumberPad"))
         {
             keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.NumberPad);
         }
         if(GUI.Button (new Rect(10, 550, 200, 100), "PhonePad"))
         {
             keyboard = TouchScreenKeyboard.Open ("", TouchScreenKeyboardType.PhonePad);
         }
         if(GUI.Button (new Rect(10, 650, 200, 100), "NamePhonePad"))
         {
             keyboard = TouchScreenKeyboard.Open ("", TouchScreenKeyboardType.NamePhonePad);
         }
         if(GUI.Button (new Rect(10, 750, 200, 100), "EmailAddress"))
         {
             keyboard = TouchScreenKeyboard.Open ("", TouchScreenKeyboardType.EmailAddress);
         }
         
     }
 }
 
              $$anonymous$$y problem is that the code provided does not work. You can try, but I have read the same code. Believe me, I have done my research.
Answer by JKXM · Jun 30, 2017 at 07:54 PM
Should this work while using Unity Remote 5? @ chetanisinanand
Your answer