Keybind
Captures a key from the user, then calls you every time it is pressed.
The smallest keybind#
main:Keybind({
Text = "Toggle aimbot",
Callback = function()
aimbot = not aimbot
end,
})Click the control, press a key, and it is bound. Callback runs on every press
of that key from then on. While it is listening, Escape or a mouse click cancels
and keeps the old key.
Preview
My Script
v1.0
Search…
Ember v1Panic key
Building it up#
Pick a starting key:
main:Keybind({
Text = "Toggle aimbot",
Default = Enum.KeyCode.E,
Callback = toggleAimbot,
})React to rebinding. Changed fires when the user picks a new key, which is
separate from that key being pressed:
main:Keybind({
Text = "Toggle aimbot",
Default = Enum.KeyCode.E,
Callback = toggleAimbot,
Changed = function(key)
print("now bound to", key.Name)
end,
})Remember it:
main:Keybind({
Text = "Toggle aimbot",
Default = Enum.KeyCode.E,
Save = "aimbotKey",
Callback = toggleAimbot,
})Every option#
| Option | Type | Default | What it does |
|---|---|---|---|
Textreq | string | — | The label. |
Callback | function(EnumItem) | — | Called with the bound key each time it is pressed. Not called when Roblox has already handled the press, such as while typing in a text box. |
Default | EnumItem | string | — | The starting key: Enum.KeyCode.E, or the name "E". |
Changed | function(EnumItem) | — | Called when the user binds a different key. |
Description | string | — | A quieter second line. |
Icon | string | — | An icon shown before the label. |
HoverColor | Color3 | string | — | The border colour on hover. A theme role name works too. |
HoverFill | Color3 | string | — | The background colour on hover, or a theme role name. |
Save | string | boolean | — | Persist the bound key. true derives a storage key from the section and label. |
Tooltip | string | — | Shown while the pointer is over the control. |
Disabled | boolean | false | Refuses input and dims the control. |
DisabledReason | string | — | Shown as a tooltip while it is disabled. |
Methods#
| Method | Returns | What it does |
|---|---|---|
Get() | EnumItem or nil | The currently bound key |
Set(key) | true, or false, reason | Rebinds it. Takes a KeyCode, a key name, or nil to unbind. |
local bind = main:Keybind({ Text = "Toggle", Default = Enum.KeyCode.E })
bind:Get() --> Enum.KeyCode.E
bind:Set(Enum.KeyCode.RightAlt) -- rebinds
bind:Set("RightAlt") -- the same, by name
bind:Set(nil) -- unbound; the control reads "None"Set fires Changed, not Callback. Pass true as a second argument to skip
Changed too.
The window has a separate keybind
The key that hides and shows the whole window is set on
Ember.new with its Keybind
option, and defaults to RightShift. A Keybind control is for your script's
own actions.