|
-
Dec 13th, 2009, 10:57 AM
#1
Thread Starter
Lively Member
onkeypress event
I want to add a ; at the end of the current line I'm typing on by using ctrl+end or other keys.. im using a richtextbox.. Thanks in Advance!
-
Dec 13th, 2009, 12:16 PM
#2
Fanatic Member
Re: onkeypress event
I'm not exactly clear on what you're asking but here's code to use the Alt key, Ctrl key and F1 key, etc.
Code:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.Alt Then
' Code to do this that or the other thing when Alt key is pressed
Select Case e.KeyCode
Case Keys.End
' Code to perform when Alt key and End key are pressed at the same time
Case Keys.Home
' Code to perform when Alt key and Home key are pressed at the same time.
End Select
End If
Select Case e.KeyCode
Case Keys.ControlKey
' Code to perform when Control key is pressed
Case Keys.Escape
' Code to perform when Escape key is pressed
Case Keys.F1
' Code to performed when F1 key is pressed
Case Keys.F2
' Code performed when F2 key is pressed
Case.Keys.End
If e.Control Then
' If Control key and End key are pressed then do whatever
' There may be some other way to code this but this is the
' way I know.
End If
End Select
End Sub
In my application I have a boolean variable ControlPresssed. If the control key is pressed ControlPressed is set to true and stays true for a couple seconds and if a certain other key is pressed while ControlPressed is true then I make something or other happen. That way you don't have to hold 2 keys down together but you can do things however you like.
 Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.
"Persistence is the magic of success." Paramahansa Yogananda
-
Dec 14th, 2009, 10:03 AM
#3
Thread Starter
Lively Member
Re: onkeypress event
I just rephrase it. Whenever the Enter Key is used it will add ; at the end of the current line in the richtextbox.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|