KeyPress事件在Lua? [英] KeyPress event in Lua?

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

问题描述

是否可以让用户按下lua键?
fe。

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.

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

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