vibration in android and lock key

Have some function to add vibration in the android and how can i setting the function when the user click the lock key on the android device?