Storing Joystick movements, key depressed time

I have need to record both the length of time a key has been depressed for, and expanding beyond this to store joystick movements. What data type and method can I use to store joystick movements?

I am trying to apply an equal and opposite force automatically to an object by creating a method that will run upon user key or joystick input and apply the opposite of input after input ceases.

Use the input manager built into Unity3D (Edit -> Project Settings -> Input) The keys defined here have a couple of variables that I think have exactly what you need. The reference to what they are you can see here

Btw nice title, I didn't know keys could be sad.

EDIT:

If you want to make your own code

Get 2 states stored

Pressed this frame Pressed previous frame

if !pressed previous frame and pressed this frame means key is held down while it's held down ( update routine) Increase a time value. And presto chango you have a measurement system in code for the time it has been measured Just don't forget to reset it if needed.