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!

Recommended Answers

All 6 Replies

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.

Thanks a lot! Now how do I block CTRL+ALT+DEL?

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?

Or access the registry with the Microsoft.Win32.Registry class

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.