- Home /
Problem with Keycode.Plus
Hi,
currently I'm trying to detect User-Input. I want to print a string when the user presses the Plus-Key on the Keyboard and I've written a little Javascript function, but it doesn't work as expected.
function Update () {
if(Input.GetKey(KeyCode.Plus))
print("PLUS (normal)");
if(Input.GetKey(KeyCode.KeypadPlus))
print("PLUS (Keypad)");
}
When I run it, "PLUS (normal)" gets never printed, when I hit the Plus-Key on the Keyboard. The Plus-Key on the Keypad works as expected. When I press it, "PLUS (Keypad)" gets printed to the Console. But I need access to the Plus Key on the normal Keyboard because most Laptops don't have a Keypad. Does somebody of you know, how to fix that?
Thank you from Germany.
Answer by Eric5h5 · May 07, 2012 at 09:32 AM
Do you have an actual plus key on your keyboard layout? It doesn't work on a US keyboard either, but in that case the plus is actually shift-equals, in which case you use KeyCode.Equals for the actual key, and if you wanted to detect plus then you'd check for the shift key down as well.
Thank you very much for your answer. It helped me a lot. The following code did the trick for me:
Input.Get$$anonymous$$ey($$anonymous$$eyCode.Equals);
Answer by unitron · May 07, 2012 at 10:10 AM
Problem fixed (for all the users with german Keyboard-Layout): You can get Access to the Plus-Key with Input.GetKey(Keycode.Equals)
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Checking whether string is a valid Input.Key 1 Answer
How can I synchronize the cooldown on two separate scripts? 2 Answers
GUI for Keyboard controls 0 Answers
Unity config file/or reg key 1 Answer