Escape key not being detected?


#1
userInputService.InputBegan:Connect(function(input, GPE)
	print(1)
	if not GPE then
		print(2)
		if input then
			print(3)
			if var.editing then
				print(4)
				if input.KeyCode == Enum.KeyCode.Escape then
					print(5)
					cancel()
				end
			end
		end
	end
end)

Doesn’t print anything when pressing Escape. It prints all the other numbers, but not when I press Escape


#2

The escape key is used to open the CoreGui menu, so this wouldn’t get past if not GPE then because the game has processed that input to open/close the menu.

You typically shouldn’t use the escape key for your keybinds. If you’re trying to do something when the menu opens/closes instead, use these API members:
https://developer.roblox.com/api-reference/event/GuiService/MenuOpened
https://developer.roblox.com/api-reference/event/GuiService/MenuClosed