Help With KeyCode Bytes

Hello everyone,

So recently I have been working on UI and decided to work on a custom keybind script, after doing around 3 days of research I have found really no solution to my problem of understanding how to use Keybinds, and the methods I found are depricated.

So here is the article in Developer page about KeyCode but my script below unfortunately doesn’t detect input, and I am unsure what I am doing incorrectly.
InputObject.KeyCode (roblox.com)

local function inputBegan(input)
if input.KeyCode == 8 then
	print("Backspace Works")
    end
end

UserInputService.InputBegan:Connect(inputBegan)

Help will be greatly appreciated on this problem.

Yo have to use the Enum for the KeyCode as that’s what the input’s KeyCode contains, an Enum, giving it the name or the byte wont work

Perhaps try

local function inputBegan(input)
if input.KeyCode == Enum.KeyCode.Backspace then
	print("Backspace Works")
    end
end

UserInputService.InputBegan:Connect(inputBegan)

Autofill should show you the right Enum For backspace if I’m wrong

Thank you, but my main method would be to use an int value that can change when the player picks a different keybind.

local OpenMenuButton = 8

Like this above ^

I’m not sure how you could do that, perhaps in y our code, do

local function inputBegan(input)
if input.KeyCode.Value == 8 then
	print("Backspace Works")
    end
end

UserInputService.InputBegan:Connect(inputBegan)

Since in the Article for KeyCodes, a KeyCode contains a name, value, and description. So if you reference Value, it should work

1 Like

Thank you so much, this worked!

1 Like

Anytime! If you have anymore issues don’t be afraid to make another post!!

1 Like

Thank you, I hope that this helps other people who also want to make custom keybinds for their game.

1 Like