Skip to content
Claude edited this page Oct 27, 2026 · 10 revisions

Blitz3DBlitzPlusBlitzBasic

KeyHit

KeyHit:Int32 key:Int32
Parameter Type Default Description
key Int32 required The scancode of the key, 1 to 255.

Returns: How many times the key was pressed since the last call.

Description

Counts how often a key was pressed since the last time KeyHit asked about that same key. The count starts again from zero on every call, so the key must be released and pressed again to count another time. This is the right choice for one-shot actions like pausing or shooting, while KeyDown suits continuous movement.

Examples

Graphics 320, 240, 0, 2
SetBuffer BackBuffer()
Local hits = 0
While Not KeyHit(1)
	If KeyHit(57) Then hits = hits + 1
	Cls
	Text 10, 10, "Press Space, Escape ends"
	Text 10, 30, "Space was pressed " + hits + " times"
	Flip
Wend

Related Commands

GetKey, KeyDown, KeyWait, WaitKey

Home · Command Index


Getting started

Language

Tools


Language Features
BlitzBasic
Blitz3D
BlitzPlus
Differences

More

Clone this wiki locally