I’m currently creating a plugin, And I’d like to make keybinds in the plugin.
I’ve read this Post: Using keybinds in plugins however i don’t understand it alot. is there anyway someone can help me with this?
I’m currently creating a plugin, And I’d like to make keybinds in the plugin.
I’ve read this Post: Using keybinds in plugins however i don’t understand it alot. is there anyway someone can help me with this?
For keybinds in Plugins, you really only have to options.
##1) UserInputService
Exactly as you would in-game.
local UserInputSevice = game:GetService("UserInputService")
UserInputSevice.InputBegan:Connect(function(input, handled)
print("Key pressed!")
. . . etc
end)
File > Advanced > Customize Shortcuts
First, we need to create an action. This is the keybind that can be set.
(From Plugin - CreatePluginAction)
local myAction = plugin:CreatePluginAction(
"mycustomaction",
"Delete nuisances",
"Delete nuisance parts and instances in the workspace",
"rbxasset://textures/sparkle.png",
true
)
Second, we need to add an event handler for when the action is triggered. This is pretty simple.
myAction.Triggered:Connect(function()
print("Deleting nuisances...")
. . . etc
end)
Finally, we need to give the action a key to bind to.
**Disclaimer: ** This must be done each time by the end user no matter what. You cannot supply a default AFAIK
Go to File > Advanced > Customize Shortcuts
and type into the search bar the name of your action. In this case we set it to “Delete nuisances”, so you can type something similar to find it.
Then, just give it a shortcut in the “Shortcut” column and click “OK” at the bottom of the dialog.
–
See which one best suits your use-case and let me know if you need any further help or if any information is missing or incorrect.
Good luck!
so technically you can’t really make in - built keybinds, correct?
What do you mean? Like, they work by default?
You can with UserInputSevice, but it has its cons (read above)
You cannot with plugin actions.
If plugin menus are what you’re after, you can detect input via UserInputService and display them manually within your plugin.
basically what i need to for example you press ‘K’ and something happens. But i need it to be inbuilt
What exactly happens? That’s quite important.
Does it affect the 3D view or does it affect the explorer, for example?
i basically am making a plugin that’s similar to the output. I have a clear button, but i thought it would be nice to have a quick clear when you can just press a keybind
Ah, I see. As I see it, you’d want this to work anywhere within the Studio.
For that I’m afraid you’ll have to deal with the limitations of plugin actions and having each user set it manually. You can display an instructional prompt on how to do it if you like.
Even if it’s not as intuitive, I feel like as a user if I were to use your plugin, I would appreciate it as a feature, so go ahead and implement it if you like.
alright. I’ll make a mini notification thing that prompts you