✓ Accepted answer
Due to KeyDown becoming deprecated, using UserInputService is the only way to get the press of a key. In order to use UserInputService, you must first use :GetService() and from there you can use the InputBegan event so that you can tell when the person gives any form of input. From here you can just use a simple function with parameters to figure out which key they pressed. You will need the KeyCode List in order to find the KeyCodes of keys that you don't know.
Please note that this is not a complete script but is merely the function that you would use to find a pressed key.
game:GetService("UserInputService").InputBegan:connect(function (input, _)
if input.KeyCode == enum.KeyCode.W then
print("the player pressed W")
end
end)
2 comments
In line 2 it should be Enum.KeyCode.W not enum.KeyCode.W
Sorry my bad