How to make it so that when I press the G button, will my character throw away the weapon he is holding?

How can i do this?