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
1
Question by Jerdak · Jun 01, 2011 at 08:29 PM · inputkeyboard

Keyboard Ctrl + 1 Input Problem

Is there a way to handle grouping keyboard inputs like Ctrl+[numeric]? Example: Ctrl+1, Ctrl+2, etc.

I've tried the following:

 if(Input.GetKey("left ctrl"){
      if(Input.GetKeyDown("1"){
           Debug.Log("Ctrl+1 Down");
      }
 }

If I change the "left ctrl" to a "left alt" then there aren't any problems, otherwise it seems like Control is blocking access to the other characaters.

Alt is already bound to another action so it'd be really nice if I could use Ctrl.

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

3 Replies

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

Answer by JMGoebel · Jul 18, 2012 at 10:29 PM

It is a very simple and logical solution and that is why it was a problem. ( The easy ones always cause the most problems!)

 if(Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.S))

{ // Do what ever you need }

In your case use KeyCode.Alpha1

I found that this will NOT work in the unity editor because CTRL is used for other things within the editor. However, when you build and run your application it will work just as expected.

I hope this helps!

Comment
Add comment · Show 1 · 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 Jerdak · Jul 19, 2012 at 12:40 AM 0
Share

Wow... I completely forgot about this question. This was posted like 2 years ago. Honestly I can't remember if I ever figured this out so I'll accept the answer since you rightly identify that Unity's editor blocks the use of ctrl in preview.

avatar image
-1

Answer by DonutOfTime44 · May 20, 2013 at 08:50 PM

Your syntax is incorrect...

 if(Input.GetKey("left ctrl")){
      if(Input.GetKeyDown("1")){
           Debug.Log("Ctrl+1 Down");
      }
 }
 
Comment
Add comment · Show 1 · 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 Bunny83 · May 20, 2013 at 09:22 PM 0
Share

-1

and this is not an answer. Why do you revive such an old question which has already been solved without adding any useful information?

btw: the syntax isn't wrong at all. $$anonymous$$aybe you've ment the function parameter but it's not syntax, it's just data.

avatar image
0

Answer by Simon V · Jun 01, 2011 at 08:32 PM

Try using Input.GetKeyDown(KeyCode.LeftControl) instead.

Comment
Add comment · Show 1 · 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 Jerdak · Jun 18, 2011 at 04:55 PM 0
Share

No luck it seems.
Tried: if( Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.LeftControl)){ if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Alpha0)||Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.$$anonymous$$eypad0)){Debug.Log("Ctrl + 1 is down"); } }

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

6 People are following this question.

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

Related Questions

What just happened to my Unity!? 3 Answers

Unity runs in background but loses keyboard input 1 Answer

What Key do you press to "Jump" in the T_T Tutorial? 2 Answers

Input.GetKeyDown doesn't work with several keys 1 Answer

checking for keyboard input with exceptions 0 Answers


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