Window:onKey(key) event


This event is fired when a key was pressed.

Parameters

key

A string that represent the key name.

Key names are defined by the following rules :
  • For digit keys 0..9, the name is the digit as a string : "0", "1" ...
  • For alphabetical keys A..Z, the name is the character as a string : "A", "B" ...
  • Any other key is represented by the Windows virtual key as a string : "VK_SPACE", "VK_RETURN", "VK_SHIFT"...
  • The full list of Windows virtual keys is available here

Return value

This event returns no value.

Example

local ui = require "ui" -- create a window local win = ui.Window("Window:onKey() sample", 320, 200) ui.Entry(win, "", 100, 75, 100):center() -- set a onKey() event : display a status bar with the pressed key function win:onKey(key) win:status("Pressed Key : "..key) end win:show() while win.visible do ui.update() end