First and foremost you need a timer. This could be a global variable or an instance (object based) variable. Think about it like a stopwatch - you press the button, time runs up and then it automatically turns off when it reaches a value.
Check over the frequently asked questions sticky as there will be a ton of useful links to help you get up to speed with the basics. If you have any problems, post up what you have and I (or someone else) will fix it for you.