KeyHit

This function gets the keyhit state of a window.

Syntax

Parameters

Returns

Returns true if the specified key is has been pressed since the last time it was checked, otherwise false is returned.

Example

keyhits = 0 
--Create a window
window = Window:Create()
context = Context:Create(window)
world = World:Create()
camera = Camera:Create()
camera:Move(0,0,-3)
local light = DirectionalLight:Create()
light:SetRotation(35,35,0)

model = Model:Box()
model:SetColor(0.0,0.0,1.0)

while true do
if window:Closed() or window:KeyHit(Key.Escape) then return false end

Time:Update()
world:Update()
world:Render()

--Press the space key to see the result
if (window:KeyHit(Key.Space)) then keyhits = keyhits + 1 end
context:SetBlendMode(Blend.Alpha)
context:DrawText("Space key hits: "..keyhits,2,2)
context:SetBlendMode(Blend.Solid)
context:Sync(false)

end