Use the arrow keys to move, press space to whistle and to pluck pikmin. Press r, b, or y to switch pikmin.
I fixed the bugs in @jeevansdhanota's code. Now it works better. I also added a limit to how far you can throw pikmin and gave yellow a higher throw. Credit to @jeevansdhanota.