简体   繁体   English

是否可以发送 keydown 事件和 key up 事件?

[英]Is it possable to send keydown event and key up event?

is there a way to send a key down and key up event in Lua?有没有办法在 Lua 中发送按键按下和按键事件? Is it possible?是否可以? (This is my first time asking a question here, I'm so nervous '~') (第一次在这里提问,好紧张'~')

I want it to help you auto-press the key without you touching anything, I am making a game in which you can press "E" to do stuff such as open door, enter car etc. and I want to make a script to troll player, and make him spam "E" (But not him pressing) and keep enter and jump out of car or opening and closing doors or else.我想让它帮助你在不触摸任何东西的情况下自动按下按键,我正在制作一个游戏,你可以在其中按“E”来做一些事情,比如开门,进入汽车等,我想制作一个脚本来控制播放器,并让他发送垃圾邮件“E”(但不是他按下)并继续进入并跳出汽车或打开和关闭门或其他。

IMPORTANT: What I want isn't detecting key down up or press, what I want is to SEND a event to key down, up and press.重要提示:我想要的不是检测按键向上或按下,我想要的是发送一个事件以向下、向上和按下。

I think, you can't really force any players and do keypress from their client.我认为,你不能真正强迫任何玩家并从他们的客户那里进行按键操作。 You can detect them but not simulate them.您可以检测它们但不能模拟它们。

You can make a gui which would disappear when you press key or the gui stays on the screen and the player can't do anything.您可以制作一个图形用户界面,当您按下按键时该图形用户界面会消失,或者图形用户界面停留在屏幕上并且播放器无法执行任何操作。

You cannot force a keypress input from their client, but what you can do is assign the same function to a different event for example,您不能强制从他们的客户端输入按键,但您可以做的是将相同的 function 分配给不同的事件,例如,

local button = script.Parent

button.MouseButton1Click:Connect(function()
--your function here--
end

--different event here--:Connect(function()
--your function here--
end

so basically run the same function with a different event, because you cannot force input from the client所以基本上用不同的事件运行相同的 function,因为你不能强制从客户端输入

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM