Lua中的KeyPress事件? [英] KeyPress event in Lua?

查看:42
本文介绍了Lua中的KeyPress事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以让用户在 lua 上按键?费.

is it possible to get users keypress on lua? fe.

while true do
    if keyPress(27)==true then
        print("You just pressed ESC")
    end
end

推荐答案

Lua 基于极端的可移植性.因此,它基于提供本质上仅在 ANSI C 中可用的功能.(我认为唯一的例外是动态链接,这是一项并非在所有平台上都可用的非 ANSI 功能,但非常有用,以至于他们已将其用于许多平台.)

Lua is predicated on extreme portability. As such it's based on supplying, essentially, only that which is available in ANSI C in terms of capabilities. (I think the sole exception to that is dynamic linking which is a non-ANSI feature not available on all platforms, but is so useful that they've put it in for many.)

ANSI C 不提供按键功能,因此默认的 Lua 库也不提供.

ANSI C doesn't provide keypress functionality so the default Lua library doesn't either.

话虽如此,LuaRocks 存储库可能会引导您找到具有此功能的库.例如,在 LuaRocks 页面上找到的 ltermbox 可能具有您需要的功能.(注意,您可能必须删除不需要的位.)可能还有其他可用的库.去挖掘.

That being said, the LuaRocks repository might lead you to a library with this capability. For example it could be that ltermbox, found on the LuaRocks page there, has the functionality you need. (You'll probably have to remove the bits you don't want, mind.) There may be other libraries available. Go digging.

否则,Lua 的全部要点就是可扩展性.它是一种可扩展的扩展语言.手工制作自己的扩展程序实际上并不难您想要的功能.

Failing that, the whole point of Lua is extensibility. It's an extensible extension language. It's not actually all that hard to hand-roll your own extension that provides the functionality you want.

这篇关于Lua中的KeyPress事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆