Key press?
Posted: Tue Mar 01, 2011 6:19 am
how can you make it tell if shift/alt/control is pushed?
like as in {SHIFT} A for cap.?
like as in {SHIFT} A for cap.?
Sharing, Teaching and Supporting coders of all ages and levels since 2009
https://www.codenstuff.com/forum/
<DllImport("user32.dll")> Shared Function GetAsyncKeyState(ByVal vKey As Integer) As Short
End Function
Private Sub btnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheck.Click
Dim res As Short = GetAsyncKeyState(Keys.LShiftKey)
If res = -32767 Then
MsgBox("Left shift is down")
End If
End Sub
If e.Shift = True And e.keycode = keys.A Then
Imports System.Runtime.InteropServices
Public Class Form1
Private WithEvents keyboard As New KeyboardHook
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Dim shift As Boolean
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
RichTextBox1.Text = TextBox1.Text
End Sub
Private Sub keyboard_KeyDown(ByVal Key As System.Windows.Forms.Keys) Handles keyboard.KeyDown
If Key = Keys.Space Then
TextBox1.AppendText(" ")
End If
If Key = Keys.Enter Then
TextBox1.AppendText(vbNewLine)
End If
End Sub
End Class
code it wrote:I think it's likethis would be if its for like a component in the program, i am using a key hook..Code: Select allIf e.Shift = True And e.keycode = keys.A Then