Turn a light off/on by pressing

I have a flash light on my person and i want to make it so he can turn it off/on by pressing “F” On the keybored. How do i do that? Thanks :smiley:

You have to write a script.

Go to youtube there you will find lot of tutorials.