(Windows) How to map keybinds to keys Studio doesn't normally support

Keybinds can expedite your workflow by enabling you to use a key to trigger something instead of a UI button which may take longer to navigate to than you’d like, and luckily ROBLOX supports keybinds by default. There are a couple keys that can’t be used though: buttons on the mouse, custom keys (e.g. volume controls) on keyboards, and the tab key (works in-game but not in Studio, at least on Windows) Luckily, there’s a way to use these keys/buttons for keybinds in the case you want to use them for anything, e.g. triggering Play and Run with two side mouse buttons for near instant testing. Keep in mind that, while the tutorial is long, it is extremely simple. It’s lengthy because it entirely explains every step that needs to be taken to achieve the end result.

What you’ll need:

AutoHotkey (< download page >, < direct download >)

AutoHotkey is a very useful tool (sadly Windows-only) that allows you to do all sorts of stuff with input. We’ll be using it to re-route key presses for keys/buttons Studio doesn’t support to keys it does support, effectively allowing us to use the unsupported keys for keybinds. You can either download it directly from this page by clicking the direct download, or go to the download page to pick a specific version to download. AHK (AutoHotkey) explains what each download is, but if you’re unsure of which one to get, just use the direct download link.


Notepad, Notepad++, AHK’s SciTE editor, or another text editor of your choice

AHK scripts can be edited in any text editor, but usage of Notepad is strongly discouraged as it isn’t tailored for programming. Notepad++ (< download >, download the Installer version) or sciTE (< download >, download the installer version) are what I suggest you use, and usage of both will be covered in this tutorial. Even if you use another text editor though, the process will be identical to the Notepad++ portion of the tutorial.

Setting up a keybind in Studio:

This doesn’t help us map keys Studio doesn’t support, but we need to know how to set up keybinds in general before we try to set up keybinds for the unsupported keys. If you already know how to set up keybinds, skip this section. You can customize keybinds in Studio under File > Advanced > Customize Shorcuts

Once the customization window pops up, you can set a keybind by selecting the row of the action you want to map to a keybind and double-clicking the entry in the shortcut column. Once you do that, you can press a key to set the keybind, or right click > Clear Shortcut to unmap it. You’ll have to search through all of the actions to see if there’s anything you’d want to change, but know that any button you see in the Quick Access Menu (area between File and Home buttons) or ribbon can be mapped to a keybind. You can use the filter to narrow down your search, but sometimes the actions have awkward names (e.g. “Off” for the no-grid button), so you may have to look through all of the items in that list to find what you’re looking for.

Choosing the keys for the keybind:

We need, at a minimum, two keys to bind an unsupported key to an action in studio. As I mentioned in the description of AHK earlier, we’ll be rerouting the unsupported key press to a key that Studio supports. In my case, I want Play to be triggered by the big button on the side of my mouse, and I’ll reroute the press to the F5 key. This is what Customize Shortcuts looks for me:

Creating an AHK script:

First we need to create an AHK script. If you downloaded sciTE for AHK, you should have an option to create one directly through right click > new > AutoHotkey Script. If you are using a different text editor, create a new Text Document instead, and change the .txt file extension to the .ahk file extension. If you don’t see file extensions, you’ll have to enable them first to be able to change the file type.

If you don't know how to enable file extensions, expand this
If you are on Windows 10 (and maybe Windows 8), go to "This PC", open the View tab in the ribbon, and check "File name extensions": ![](upload://b9IXI4NJ5SzwNKQj7G9z08NcBOZ.png)

If you are running another operating system, follow this tutorial:

Once you have your AHK script, do not double click it. That will run the script. To edit the script, right click and:

  • If you are using Notepad++, select “Edit with Notepad++”
  • If you are using sciTE, select “Edit Script”
  • If you are using another text editor, select “Open With” and open it with your text editor of preference

On the left is a screenshot of an AHK file created as an AHK file, and on the right is a screenshot of an AHK file created as a txt file with its extension type changed to ahk:

Making a functional AHK script:

If any code exists in the ahk file, you can either delete it or leave it as it is – it won’t make any noticeable difference. Go to this webpage and find the AHK equivalent of the keys you’ll be using. In my case, the keys are XButton1 (side mouse button) and F5. Once you have those, add the following three lines to your AHK script:

AHKCodeForButtonNotSupportedForStudio::
Send {KeyYouBoundToTheCustomShortcut}
Return

In my case, the AHK script is:

XButton1::
Send {F5}
Return

The syntax tells AHK to do something when the key preceeding the two colons is pressed, and the something it will do is what’s after the two colons and before the Return. This also captures the pressing of the button before the two colons, so the operating system and any other program won’t notice the side mouse button has been pressed. At this point we could run it, but let’s make it a little more complex.

Complicating the AHK script:

Instead of just having the side mouse button send Studio into Play mode, I want it to stop Play mode if it’s already started. We could probably do something roundabout like checking the color of the pause button to see if the game is currently running, but we can do something easier. Instead, we’re just going to use this:

XButton1:: 
Send {F5}
Send {F8}
Return

I have the Stop action hooked up to F8 in Customize Shortcuts. This code takes advantage of how Studio works: when you start Play mode, Studio ignores keyboard input until Play mode has loaded.When you are already in Play mode, pressing the shortcut to go into Play mode again won’t do anything. We use these two to our advantage, so stopping the game immediately after starting Play mode isn’t picked up by studio, and if Play mode is already running, F5 doesn’t do anything and the game is stopped by F8. That tiny bit of code turns my side mouse button into a toggle for Play mode.

I still have an extra button on the side of my mouse though (XButton2), so let’s hook that up to toggle Run mode (which I set to F6 in Customize Shortcuts):

XButton2::
Send {F6}
Send {F8}
Return

Our combined script which causes one side mouse button to toggle Play mode and the other side mouse button to toggle Run mode is:

XButton1:: 
Send {F5}
Send {F8}
Return

XButton2::
Send {F6}
Send {F8}
Return

Correcting some annoyances:

If we were to run our script by double clicking it, we would run into three problems:

  1. Studio is evil and likes to steal input, making it impossible for our AHK script to detect keypresses. We can prevent this by right clicking the AHK script (instead of double clicking it), and running it as an administrator

  2. We would have to run this every time we rebooted our computer, which might get annoying. You can place the script in %appdata%\Microsoft\Windows\Start Menu\Programs\Startup to have it automatically run each time the computer boots up. The problem in doing so is that it won’t start up as an administrator, so we’ll have to do something about that. Instead of putting the script in the startup folder, put a shortcut to it in the startup folder, right click and configure the shortcut’s properties, click Advanced on the Shortcut tab, and select Run as administrator.

  3. The AHK script will still run outside of ROBLOX Studio. This can be undesirable, so let’s fix that. First add this to the top of your script (but below the default code if you kept that):

RobloxStudioActive() {
    WinGet, RobloxStudio,, ahk_exe RobloxStudioBeta.exe
    WinGet, active,, A
    equal := RobloxStudio = active
    return equal
}

Then add an if statement checking if RobloxStudioActive() returns true for each keybind:

XButton1::
if (RobloxStudioActive()) {
    Send {F5}
    Send {F8}
}
Return

XButton2::
if (RobloxStudioActive()) {
    Send {F6}
    Send {F8}
}
Return

Congratulations: You are finished!

Final words: Here are some AHK alternatives for OS X

6 Likes