Class: FdKeyboard

FdTools. FdKeyboard

键盘事件类
如果按住按键不松开, 会以一秒30次的频率发送键盘事件.
可以从事件的参数中获取按键的信息.


new FdKeyboard()

Methods


disable()

禁用键盘操作器


dispose()

销毁所有资源


enable()

激活键盘操作器 激活后会自动进行按键监控,并在按下按键后触发timer事件


getStatus()

获取当前的状态

Returns:

true为激活状态

Type
Boolean

on(listener [, scope])

注册事件捕捉

Parameters:
Name Type Argument Description
listener FdTools.FdKeyboard~FdKeyboardCallback

当有事件触发时被执行的函数。事件类型有KeyPressed,StatusChanged

scope Object <optional>

listener函数执行时的绑定的对象。

Returns:

返回一个函数,调用该函数可以取消监听。

Type
Freedo.Event~RemoveCallback

reset()

重置


setStatus(status)

设置当前的状态

Parameters:
Name Type Description
status Boolean

true为激活

Type Definitions


FdKeyboardCallback(eventType, eventArg)

Parameters:
Name Type Description
eventType String

事件类型有以下几种:事件类型有KeyPress/KeyPressed/keyUp/StatusChanged/timer

eventArg Object

当事件类型为KeyPress/KeyPressed/keyUp时,返回键盘数组;当事件类型为StatusChanged,返回当前键盘事件的监控状态是否有效;当事件类型为timer时,返回按键相关信息