UIS:GetStringForKeyCode() returns blank string when arrows are pressed

Hello devs, I have been trying this code :

print(UserInputService:GetStringForKeyCode(Enum.KeyCode.Left))

but its prints out blank string like this :


Can someone tell me why this happens?

1 Like

I’m not sure but what I would use to get the string/name of a keycode would be:

function getKeyCodeName(keyCode)
	return keyCode.Name
end

“Name” is a property of an enum value.

2 Likes

I mean if I don’t want to use KeyCode like when you wan’t to use VirtualUser:SetKeyDown("left") how do I do it?

This function exist because symbols can’t be just used as EnumItem names directly and there are cases where you would want to convert, for example, Enum.KeyCode.Equals key to the string =.

2 Likes

Oh ok, thanks for explanation!