Advertisement

Multiple keystrokes registered

Started by August 01, 2021 07:30 AM
1 comment, last by Shaarigan 3 years, 3 months ago

I've started unity dev with Ben's udemy course and while working on ‘Respond to Player Input’ in the Number wizard module, I ran with an issue where a single keystroke often types out 30+ lines of console output.

if (Input.GetKey(KeyCode.UpArrow))
        {
            print("up arrow key is held down");
        }

Please guide me.

From the Unity Documentation

Returns true while the user holds down the key identified by name

Since I guess you're doing this in the Update function, it is looping up to 70 times per second depending on your framerate. So please get to know what you're doing before posting

This topic is closed to new replies.

Advertisement