Can I use scripts that apply to a single gamemode?

I don’t mean lua scripts, I mean these .cfg files in the cfg folder. I suppose that’s the same as “scripting” in Team Fortress 2.
I am a complete newb at this, So is it possible to write something that activates only when I play a certain gamemode, but is inactive otherwise? Usually when I try to bind a key it stays binded even after I restart Gmod. I’d like to make a script that binds certain buttons to do some stuff quickly once I join a certain gamemode, but the actions should be unbinded when I leave, is that possible? If so, please tell me how or direct me to a guide, since I can’t find one for Gmod. Thank you in advance.

I’m certain you can, because I remember seeing TTT related stuff in my .cfg file.