- Home /
Shift + Tab ???
How do I implement a code to execute, only when Tab is pressed while Shift is being held down?
I'm trying to be able to go to a previous Input Field using this function.
Answer by Talinro · Aug 25, 2017 at 02:15 AM
@ILoveMyDada a code like this should work :
if(Input.GetButton("Shift")) { if(Input.GetButtonDown("Tab")) { Place the code you want to execute here(); } }
You must have a Input set up as "Shift" and "Tab" to make this work
To do this go to the tab that says "Edit" and choose Project Setting > Input. Next add 2 to the current size. Two new Input should show at the bottom. Change the name of each to Shift and Tab respectively. Than in the positive button set each Input to its name.
You can also use Get$$anonymous$$ey()/Get$$anonymous$$eyDown() and use $$anonymous$$eyCodes if you don't want to have to deal with Input settings.
Thanks! It worked but it also didn't, haha.
It worked going from my 'registerConfirmPass' Input Field to the 'registerPassword' Input Field, but then it wouldn't continue.
If I kept Shift held and pressed Tab for the second time, it would just Tab forward ins$$anonymous$$d of backward, ignoring this code and implementing my other code worked out for just Tabbing forward. Any ideas?
if (Input.GetButton("LeftShift"))
{
if(Input.GetButtonDown("Tab"))
{
if (registerEmail.GetComponent<InputField> ().isFocused)
{
registerUsername.GetComponent<InputField> ().Select ();
}
if (registerPassword.GetComponent<InputField> ().isFocused)
{
registerEmail.GetComponent<InputField> ().Select ();
}
if (registerConfirmPass.GetComponent<InputField> ().isFocused)
{
registerPassword.GetComponent<InputField> ().Select ();
}
}
}
@Talinro Actually sorry, it is working but I realized my previous code is getting in the way because there are two Inputs going on for Tab. Is there any way around this? I'm thinking booleans, but maybe theres something simple I'm not seeing?
void Update()
{
if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.Tab))
{
if (registerUsername.GetComponent<InputField> ().isFocused)
{
registerEmail.GetComponent<InputField> ().Select();
}
if (registerEmail.GetComponent<InputField> ().isFocused)
{
registerPassword.GetComponent<InputField> ().Select();
}
if (registerPassword.GetComponent<InputField> ().isFocused)
{
registerConfirmPass.GetComponent<InputField> ().Select();
}
}
if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.LeftShift))
{
if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Tab))
{
if (registerEmail.GetComponent<InputField> ().isFocused)
{
registerUsername.GetComponent<InputField> ().Select ();
}
if (registerPassword.GetComponent<InputField> ().isFocused)
{
registerEmail.GetComponent<InputField> ().Select ();
}
if (registerConfirmPass.GetComponent<InputField> ().isFocused)
{
registerPassword.GetComponent<InputField> ().Select ();
}
}
}
@Talinro Never$$anonymous$$d I figured it out with a simple bool. Thanks! Sorry, I'm a mess over here.
Yes there is an easy fix:
if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Tab))
{
if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.LeftShift))
{
// shift + tab
}
else
{
// just tab
}
}
Your answer
Follow this Question
Related Questions
Noob - Use the ESC, Shift and Command Key?? 1 Answer
Language change (Hebrew) messes up input? 0 Answers
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
KeyCode.RightShift not working in Flash Player 0 Answers
Camera switching from first person to 3rd, script not working, need help plz 1 Answer