Back to Main Page

This page contains info about key input modifiers, what they are and why their explicit control is critical to co-existing with other mods.


Key Modifiers - Control is key

First question... do you know what a key modifier is?

Second question... do you know why they are important?

To answer the first question, as far as Windows is concerned, key modifiers are the Control, Shift or Alt keys. They are called modifiers because they modify the behaviour when a key is pressed. Take a simple example, you open notepad and press the 'A' key a few times and as you expect, you get a row of 'a' characters. When you press Shift, you get a row of 'A' characters. If you now press Control + A, you select all of those characters. So you can see how the 'A' key input gets modified by the other keys that are pressed.

To answer the second question, imagine you wanted to type an 'A' instead of 'a', you would hold the Shift key right? But what if doing that resulted in both actions taking place? So if you pressed Shift and 'A', you ended up with "Aa". That would be bad and make using modifiers almost impossible.

So with that in mind, what happens if you have a mod that does something with 'A' and another that does something with Shift + A? In theory, two different things should happen right? Except when the mod that works with just 'A' doesn't explicitly check for 'A' and no modifiers. Using Control and Alt with keys in GTAV can be troublesome, because those keys switch player states or trigger actions like showing the "Recording" prompt. But Shift is just the Sprint key, so is pretty safe when you're standing still or in a car.

So how do you make your mod multi-mod friendly?

If your mod uses a single key, then all you have to do in the key checking, is put this.

if (e.Keycode == Keys.[your activation key] && e.Modifiers != Keys.Shift)

Doing that means that your mod will only activate, if your key is pressed and the Shift key is not pressed. This frees up the Shift + A state for either another mod to use, or for your own mod to use a second function. For instance, in my On-Foot Cinematic Camera mod, the whole system is switched on and off with F11 (as a default setting) but the On-Foot part is switched on and off with Shift + F11. So one mod, two functions, only one key used on the keyboard.

So if you only have one function, decide if your mod is going to use modifiers and make sure you explicitly check for the state of the modifiers, even when you're not using them, even if it's just the Shift key. That way, you free up the alternate state of that key for another mod to use. I have my Pick Your Ride mod on F10, I have my Pick Your Ped mod on Shift + F10. I have someone else's mod on F8 and I can't use Shift + F8, because they don't check for the modifier. So that's a key function lost because of careless programming.

As with mod performance, you have to remember that you're in a shared sandbox and you have to play responsibly with others. Mod compatibility is already a major issue and this simple bit of key control is a small step to making it less of an issue.