Simple Hotkey System

Nothing special. Just a simple hotkey system I wrote a long time ago because F1-F4 didn’t provide me enough keys, and a gamemode I was working on required it for user simplicity.

Only reason I’m releasing is because I did a quick search of the Lua section for “hotkey” in thread titles, and I didn’t see any.

If someone already released a hotkey system, oh well.

Pictures
The main window
Hotkey assign window

Adding New Hotkeys:
To add a new hotkey, use the console command add_hotkey <command> <display>. Note that <command> MUST be a single word. Commands like impulse 101 will not work. Display can be as many words as you want. For example, if you wanted to add a suicide key, you could add it like so:


add_hotkey kill Commit Suicide

You can then open up your hotkey menu, assign a key to “Commit Suicide”, and use it to kill yourself.

Removing Hotkeys:
If you added a hotkey you don’t want any more, or you made a typo in adding a hotkey, you can remove it by using the remove_hotkey . If we wanted to, for example, remove the suicide command we added above, we would use:


remove_hotkey kill

Installation:
Put cl_hotkeys.lua in your lua/autorun/client/ folder. Make folders as necessary.

Usage:
By default, “H” is assigned to bring up the hotkey menu. You can reassign this to any key you wish, other than bad hotkeys.


BAD HOTKEYS

These hotkeys can not be used.

[ul][li]numbers 1-6 (not on the numpad), which are used for the weapons.
[/li][li]Backquote
[/li][li]Escape key
[/li][li]F1 to F4
[/li][li]Scroll-lock
[/li][li]Numlock
[/li][li]Caps-lock[/ul]
[/li]
All these are banned commands for very good reasons, usually being they would call infinitely, making your screen stuck at the “assign hotkey”, and forcing you to delete the hotkey text file and restart your Garry’s Mod to fix it.

Download:
Download from FileFront

Re-usage (For gamemodes, addons, etc)
I don’t care if you re-use this for your DarkRP edits, your Zombie Survival rehashes, your SpaceBuild version 7000, or whatever you want to use it for. I’m not going to be a jackass and Creative Commons License this, because it’s just a simple script written in twenty minutes to make my life and the life of my clients easier. If you’re going to use it, all I ask is you throw in a comment or two saying that I wrote it. Nothing more, nothing less.

You don’t even have to do that. It’s just polite to.

Enjoy.

Cool it’s like the bind command with an interface

:smug:

And it doesn’t actually bind keys.

It was designed so gamemodes can have players bind keys without actually binding their keys.

:smug:

It does work ofc :wink:


add_hotkey "impulse 101" Give all weapons

This will work since the source engine interpretes anything surrounded by
“” as one command (the first command is what you specify)


local command = arg[1]

I tried that, and it gave me a RunConsoleCommand error about invalid characters with the command “impulse 101 (’ ')”.

If you can get it to work, though, then great.

I’m really noob, could someone explain me what does it do?

Here.