Learn about detecting keyboard input in roblox!
Code:
--function declared separately
local function myFunction(input, gameProcessed)
if gameProcessed then return end --stops function if game already processed input
if input.KeyCode == Enum.KeyCode.K then
print("K was pressed")
end
end
game:GetService("UserInputService").InputBegan:Connect(myFunction)