Hi there, I'm creating a program and I need to block out the keyboard completely. Including every button and key combo. Is there a way to do this? I already scoured the internet... any help would be greatly appreciated!

8 Years
Discussion Span
Last Post by bigtreeworld

This should do the trick:

Public Class frmKeyboard

	Private Sub frmKeyboard_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
		'Stops user key presses
		e.Handled = True
	End Sub

	Private Sub frmKeyboard_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		'Give the form access to key presses before the focused control
		Me.KeyPreview = True
	End Sub

	Protected Overrides Function ProcessDialogKey(ByVal keyData As System.Windows.Forms.Keys) As Boolean
		'This stops it from processing keys such as tab/enter
		'Return MyBase.ProcessDialogKey(keyData)
	End Function
End Class

This will not stop CTRL+ALT+DEL and keys that windows handle.


i would say thats pretty dangerous to block windows hotkeys. coz sometimes they are your last chance :p
anyway first i thought using the unregisterhotkey API would be the way to go but realised thats impossible to get the atomID of each hotkey so i did some google and found this article

Modifying your system’s registry can cause serious problems that may require reinstalling your Windows OS.

i just can second that. make sure it is REALLY needed in your application.


Sweet, now how can I use VB to implement that? Would I have to run a .reg file?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.