Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ILoveMyDada · Aug 25, 2017 at 02:08 AM · inputtabshift

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

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.

Comment
Add comment · Show 8 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sleepandpancakes · Aug 25, 2017 at 02:36 AM 0
Share

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.

avatar image ILoveMyDada · Aug 25, 2017 at 02:37 AM 0
Share

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 ();
             }

         }
     }
avatar image ILoveMyDada · Aug 25, 2017 at 09:05 AM 0
Share

@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 ();
             }

         }
     }
avatar image ILoveMyDada ILoveMyDada · Aug 25, 2017 at 09:36 AM 0
Share

@Talinro Never$$anonymous$$d I figured it out with a simple bool. Thanks! Sorry, I'm a mess over here.

avatar image Bunny83 ILoveMyDada · Aug 25, 2017 at 09:50 AM 1
Share

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
     }
 }

Show more comments
Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

80 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges