few examples
forced keybind
GlobalActionMap.bindCmd(keyboard, "f6", "", "toggleBGMusicGui();");
simple custom keybind
if (!$AutoJet::addedJet)
{
$remapDivision[$remapCount] = "Auto-Jet";
$remapName[$remapCount] = "Activate/Deacticate";
$remapCmd[$remapCount] = "activateJet";
$remapCount++;
$remapName[$remapCount] = "Elevate";
$remapCmd[$remapCount] = "autoJetHeightUp";
$remapCount++;
$remapName[$remapCount] = "Decend";
$remapCmd[$remapCount] = "autoJetHeightDown";
$remapCount++;
$AutoJet::addedJet = true;
}
more complex custom keybind (can add to existing divisions)
//Hug toggle, keybind code ripped from Ephialtes' quicksave, and commandtoserver('unusetool'); was suggested by Ephialtes
//Stolen from Ephialtes who stole from Randy
function AddBind(%division, %name, %command)
{
for(%i=0;%i<$remapCount;%i++)
{
if($remapDivision[%i] $= %division)
{
%foundDiv = 1;
continue;
}
if(%foundDiv && $remapDivision[%i] !$= "")
{
%position = %i;
break;
}
}
if(!%foundDiv)
{
error("Division not found: " @ %division);
return;
}
if(!%position)
{
$remapName[$remapCount] = %name;
$remapCmd[$remapCount] = %command;
$remapCount++;
return;
}
for(%i=$remapCount;%i>%position;%i--)
{
$remapDivision[%i] = $remapDivision[%i - 1];
$remapName[%i] = $remapName[%i - 1];
$remapCmd[%i] = $remapCmd[%i - 1];
}
$remapDivision[%position] = "";
$remapName[%position] = %name;
$remapCmd[%position] = %command;
$remapCount++;
}
if(!$HugToggleBound)
{
AddBind("Emotes", "Hug", "togglehug");
$HugToggleBound = true;
}
edit:
here's a bit more of the BGMusic GUI opening/closing code, in case it helps you
GlobalActionMap.bindCmd(keyboard, "f6", "", "toggleBGMusicGui();");
function toggleBGMusicGUI()
{
if(BGMusicGui.isAwake())
canvas.popDialog(BGMusicGui);
else
canvas.pushDialog(BGMusicGui);
}