[KEYSTROK] Open-Sourced: Key-Binding / Key-Combo?

KeyStrokLogo

Single/multi-key binder for Roblox. Ties actions to one key or multiple keys. Easy input tool for game controls. Saves events in table. Simple, flexible.

Use?

You can bind Keybinds using the name of the key or Enum:

local KeyStrok = require(script:WaitForChild("KeyStrok"))

local EventA = KeyStrok({Enum.KeyCode.W},function()
	print("1")
end)
EventA:Disconnect()
local EventA = KeyStrok({"W"},function()
	print("1")
end)

You can bind similar structure key combination just like:

local KeyStrok = require(script:WaitForChild("KeyStrok"))
local EventC = KeyStrok({"W"},function()
	print("1")
end)
local EventB = KeyStrok({"W","D"},function()
	print("2")
end)
local EventC = KeyStrok({"W","D","E"},function()
	print("3")
end)

How?

Under the hood, click me!

7 Likes

Thanks for the module! Will use it in my future projects.

2 Likes

[UPDATE 1] Key Held Detection:

(you can get new version from toolbox link above)

KeyStrok(KeyList,Callback,isHeld)
--[[
put true or anything 
if you want it to be detect for holds
]]

Example Usage:

local KeyStrok = require(script:WaitForChild("KeyStrok"))

local A = KeyStrok({"W"},function(IsHeld)
	if IsHeld then
		print("held")
	else
		print("not held")
	end
end,true)

KeyStrok({"W","D"},function()
	warn("combo!")
end)

local A2 = KeyStrok({"W","D"},function(IsHeld)
	print("combo held!",IsHeld)
end,true)

Behavior:
If your detecting for W or W+D, on holds, it will return nil on the event it’s released or another Key has been added to the list, so it!

Example’s Output:

P.S. REMEBER TO PROPERLY DISCONNECT WHEN YOU DONT WANT EVENT

local A = KeyStrok({"W"},function(IsHeld)
	if IsHeld then
		print("held")
	else
		print("not held")
	end
end,true)

A:Disconnect()
A = nil

Reason i’ve added update:

Hi,
For the silly question, is this reading when the player does the combo?

Also is there anyway of adding a feature where it could limit how fast a player could do a combo… do slow down the input of players that use programmable keys that react faster then what a human could do? Thanks

local CoolDown = 5

local ComboEvent do
	local LastUsage
	ComboEvent = KeyStrok(Combo,function()
	if LastUsage and (LastUsage - os.clock() ) <= CoolDown then return end
	LastUsage = os.clock()
	-- Combo Function Below
end)

-- How to clean:
ComboEvent:Disconnect()
ComboEvent = nil
2 Likes