📜  roblox 按键脚本 - Lua 代码示例

📅  最后修改于: 2022-03-11 14:54:55.058000             🧑  作者: Mango

代码示例2
local UserInputService = game:GetService("UserInputService")
local Key = Enum.KeyCode.WhateverKey

UserInputService.InputBegan:Connect(function(InputObject, GameProcessedEvent)
    if GameProcessedEvent then return end
    if InputObject.KeyCode = Key then
      print("Player pressed "..InputObject.KeyCode)
    end
end)