Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Seth-McCumber · Nov 12, 2013 at 08:43 PM · inputkeyboardkeycode

Turn Currently Held Button To A KeyCode(C#)

Hello Again Unity Answers! Im Back Yet Again For Another Question That IM SUre You Already Know(If You Read The Title), Here It Goes-

I Was Wondering If There Was A Way To Turn Any Currently Held Button Into A KeyCode. I Have Seen Ways To Turn Some Keys Into KeyCodes And That Is lIke This

 void OnGUI() {
 
          Event e = Event.current;
         if(e.isKey) {
             print(e.keyCode);
         }
     }

Yet That Only Returns Some Characters Which Dont Include Shift, CapsLock, Mouse Buttons And Possibly Others Im Unaware Of. I Want To Be Able To Turn Any Key Thats Pressed Down At All To Turn Into A KeyCode. If You Are Wondering, This Will Be Used For Custom Control Setup In My Game. My Last Idea Which as To Turn A Button To A String To Use With GetKeyDown Did Not Work, And This Is My New Idea. Thanks For Any Help Given!

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
0

Answer by Dracorat · Nov 12, 2013 at 08:57 PM

A) Please Don't Type In Mixed Case.

B) If you want to know whether a modifier key (such as shift etc) is being held along with the key in question, e.Modifiers will tell you.

If I recall how modifiers works correctly, testing for shift is like:

if(e.modifiers && EventModifiers.Shift) { /*Shift was also pressed with this button*/ }

C) Pressing shift, etc should also have their own code.

D) More appropriate however, would be the use of Input.GetKeyDown

http://docs.unity3d.com/Documentation/ScriptReference/Input.GetKeyDown.html

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 Seth-McCumber · Nov 12, 2013 at 09:04 PM 0
Share

For Answer Part D, Im Not Using It To Detect If The $$anonymous$$ey Is Being Held Down, Im Trying To Use It To Change A $$anonymous$$eyCode To The Button Im Holding Down At A Certain Time(In This Case, In The Options)

avatar image roojerry · Nov 12, 2013 at 09:25 PM 0
Share

Please also consider his point A. It is a real pain to read your questions with your improper use of sentence casing. For the sake of people helping you, save yourself the trouble of pressing Shift for every single word. I, for one, would be more inclined to help you if reading your questions and comments wasn't such a chore.

avatar image Seth-McCumber · Nov 12, 2013 at 09:27 PM 0
Share

I will try

avatar image Dracorat · Nov 12, 2013 at 10:36 PM 0
Share

It requires a lot of coding. Luckily someone has done the heavy lifting for you already...

http://forum.unity3d.com/threads/53726-Custom-Inputmanager-v1-4-VERY-easy-to-use-now-!

avatar image Seth-McCumber · Nov 12, 2013 at 10:56 PM 0
Share

I have known about cInput for quite some time. Im just not sure about it since it changes the input asset in unity(im very overprotective of my computer :D)

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

18 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

Related Questions

KeyCode and ? (question mark keyboard) 1 Answer

Shift + KeyCode.Equals works in Unity Editor but not on WebGL build 0 Answers

Key not recognized 2 Answers

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

Input.GetKeyDown doesn't work with several keys 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