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

A lot of incomprehensible. Could you explain it in more detail?