Read inputs from keyboard or usb

I am a newbie to Unity. I am working on a project, and i want to use Unity for it, Does anybody have an idea of how to write scripts for reading inputs from the keyboard or inputs from usb? what language is good for that; C# or Java script? Thanks


Javascript or c# don't make too much difference if you are debuting I think.

Reading inputs from the keyboard:

check the help, it's actually very straight forward:

Here is simplier example in javascript:

function Update () {

        Debug.Log("You have pressed "+Input.inputString);


Unity provides also an extra layer in between the application and user inputs, it allows you to define how the mouse, keyboard and joystick(s) behave. It makes it easy to query and work with ( to a certain extent as always...)

now, reading from a usb is a totally difference matter and will require that you write your own plugin ( dll or objective-c if targeting iOS), tho, if you want to read from a joystick, then it's as simple as reading the keyboard. You will require unity Pro if you want to write plugins.

A very good starting point to learn about writing plugins is this example from unity resources.

Hope this helps,


Hey Jean, Im a newbie to Unity 3d. But I need ideas about a project I want to work on. Its a test tool for a motor bike in which there will be a motorbike (like in a game), but the acceleration comes from the real bike. Someone is already working on collecting inputs from the bike and sending it to the usb port. But how do I get inputs to control acceleration in Unity? Thanks