Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is the PlayerMouse not firing KeyDown when F key pressed?

This used to work fine, but last week or so I noticed that the F key control wasn't working in my game.

I just now did a simple test:

function keydown(k)
	print(k);
end

m = game.Players.LocalPlayer:GetMouse();
m.KeyDown:connect(keydown)

... and "f" wasn't printed when I pressed the 'f' key (though everything else works).


Why is the f key now protected?

Can I do something to get around this? Will using a tool work? Can I do that will hiding the ROBLOX tool GUIs and avoiding other UI annoyances?

2 answers

✓ Accepted answer

I know this question is super old, but since it isn't locked:

You can use the UserInputService now to get around this:

local uis = game:GetService("UserInputService")

uis.InputBegan:connect(function(inst)
	if inst.KeyCode == Enum.KeyCode.F then
		print("f key pressed")
	end
end)

To get around protected keys, you will unfortunately have to use KeyUp. This is what I did when I wanted "/" to be a key that worked in my game. Sorry if you REALLY want to use KeyDown for "f," this probably wasn't the answer you wanted lol. If that is the case then I suggest sending a message to roblox about your request to fix these protected keys. (And yes, "f" is one of my hotkeys in my game too so "f" will work with KeyUp, but I figured I'd use "/" as an example xD)

This discussion is preserved as it was. New answers, comments, and votes are closed.