x


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.

more ▼

asked May 07 '12 at 08:39 AM

unitron gravatar image

unitron
3 5 5 6

(comments are locked)
10|3000 characters needed characters left

2 answers: sort newest

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.

more ▼

answered May 07 '12 at 09:32 AM

Eric5h5 gravatar image

Eric5h5
80.3k 42 132 521

Thank you very much for your answer. It helped me a lot. The following code did the trick for me:

Input.GetKey(KeyCode.Equals);
May 07 '12 at 10:10 AM unitron
(comments are locked)
10|3000 characters needed characters left

Problem fixed (for all the users with german Keyboard-Layout): You can get Access to the Plus-Key with Input.GetKey(Keycode.Equals)

more ▼

answered May 07 '12 at 10:10 AM

unitron gravatar image

unitron
3 5 5 6

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3741
x956
x22

asked: May 07 '12 at 08:39 AM

Seen: 569 times

Last Updated: May 07 '12 at 10:35 AM