Capturing CAPS lock

BlitzPlus Forums/BlitzPlus Programming/Capturing CAPS lock

Neo Genesis10(Posted 2003) [#1]
Hiya guys. Currently there is no native Blitz 3D/2D function to get the status of the caps lock key (On or off). Does anyone have any userlibs or similar ways of getting access to this?


DJWoodgate(Posted 2003) [#2]
You could try setkeyboardstate and getkeyboardstate in User32. No idea if they will work in blitz though I have not tried them, but it would be nice if they did. I expect there will be compatibility issues though.


EOF(Posted 2003) [#3]
See if this works. It shows CAPS Lock, Scroll Lock, NumLock, and Insert status:

; keyboard State

; userlibs
; ***********************************************
; .lib "user32.dll"
; GetKeyboardState%(state*):"GetKeyboardState"
; ***********************************************

Const VK_CAPITAL = $14
Const VK_NUMLOCK = $90
Const VK_SCROLL = $91
Const VK_INSERT = $2d

kstate=CreateBank(256)

Graphics 400,300,0,2
SetFont LoadFont ("courier",20)

Repeat
	GetKeyboardState(kstate)
	Cls
	Text 10,10,"Caps       = "+PeekByte(kstate,VK_CAPITAL)
	Text 10,30,"Numlock    = "+PeekByte(kstate,VK_NUMLOCK)
	Text 10,50,"Scrolllock = "+PeekByte(kstate,VK_SCROLL)
	Text 10,70,"Insert     = "+PeekByte(kstate,VK_INSERT)
	Flip
	Delay 5
Until KeyHit(1)

End