跳到主要内容

Keyboard

描述:

  用于处理键盘事件的接口类。

Keyboard.KeyName

类型: 枚举。

描述:

  键盘按键名称的枚举。

签名:

enum KeyName
"Return"
"Escape"
"BackSpace"
"Tab"
"Space"
"!"
"\""
"#"
"%"
"$"
"&"
"'"
"("
")"
"*"
"+"
","
"-"
"."
"/"
"1"
"2"
"3"
"4"
"5"
"6"
"7"
"8"
"9"
"0"
":"
";"
"<"
"="
">"
"?"
"@"
"["
"\\"
"]"
"^"
"_"
"`"
"A"
"B"
"C"
"D"
"E"
"F"
"G"
"H"
"I"
"J"
"K"
"L"
"M"
"N"
"O"
"P"
"Q"
"R"
"S"
"T"
"U"
"V"
"W"
"X"
"Y"
"Z"
"Delete"
"CapsLock"
"F1"
"F2"
"F3"
"F4"
"F5"
"F6"
"F7"
"F8"
"F9"
"F10"
"F11"
"F12"
"PrintScreen"
"ScrollLock"
"Pause"
"Insert"
"Home"
"PageUp"
"Delete"
"End"
"PageDown"
"Right"
"Left"
"Down"
"Up"
"Application"
"LCtrl"
"LShift"
"LAlt"
"LGui"
"RCtrl"
"RShift"
"RAlt"
"RGui"
end

isKeyDown

类型: 函数。

描述:

  检查当前帧中是否按下了某个键。

签名:

isKeyDown: function(self: Keyboard, name: KeyName): boolean

参数:

参数名类型描述
nameKeyName要检查的键的名称。

返回值:

返回类型描述
boolean按键是否按下。

isKeyUp

类型: 函数。

描述:

  检查当前帧中是否释放了某个键。

签名:

isKeyUp: function(self: Keyboard, name: KeyName): boolean

参数:

参数名类型描述
nameKeyName要检查的键的名称。

返回值:

返回类型描述
boolean按键是否已释放。

isKeyPressed

类型: 函数。

描述:

  检查某个键是否处于按下状态。

签名:

isKeyPressed: function(self: Keyboard, name: KeyName): boolean

参数:

参数名类型描述
nameKeyName要检查的键的名称。

返回值:

返回类型描述
boolean按键是否处于按下状态。

updateIMEPosHint

类型: 函数。

描述:

  更新系统输入法(IME)弹出的位置提示。

签名:

updateIMEPosHint: function(self: Keyboard, winPos: Vec2)

参数:

参数名类型描述
winPosVec2弹出输入法窗口的位置。