| | |
Alt+some key in KeyPress event
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Dec 2008
Posts: 14
Reputation:
Solved Threads: 0
hi, i am using rtb. I want to print a specific character when user presses Alt+some key by using chrW() method. I want to detect in KeyPress() event of rtb when user presses Alt+Key. How can i do that? I know i can detect (Alt+x) like combinations in Key_Down event of rtb and then i have used KeyCode = (decimal value of character to be printed). but its not working
use sendkeys or API Function.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
It already works using the number pad (ie: alt + 251 or whatever), but to do it how you want, you must subclass the form (which is kind of ugly), can't you just on keyup or keydown do something like this:
or am I missing what you need?
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
richtext1.text = richtext1.text & chrw(keycode)
Unfortunately, alt isn't a standard key... so you're pretty much going to have to use the key up and key down events if you want full detection of what they're doing...
is key down - alt is keycode 18 shift 4, key up - just keycode 18 since it's no longer pressed...
numbers on the numeric keypad are listed as 96 through 105 (0 through 9) as opposed to 48 through 57 at the top of the keyboard.
you could do it this way, but it could probably be written better... (4:50 am, im tired)
also though i don't see why you wouldn't just let the user type stuff in with the alt keys / numeric keypad on their own? i'd think it would double type if you both convert their input and make them type it in..? ie: alt 097 would produce 'a' normally, but coding control for it as well would produce 'aa', no?
is key down - alt is keycode 18 shift 4, key up - just keycode 18 since it's no longer pressed...
numbers on the numeric keypad are listed as 96 through 105 (0 through 9) as opposed to 48 through 57 at the top of the keyboard.
you could do it this way, but it could probably be written better... (4:50 am, im tired)
also though i don't see why you wouldn't just let the user type stuff in with the alt keys / numeric keypad on their own? i'd think it would double type if you both convert their input and make them type it in..? ie: alt 097 would produce 'a' normally, but coding control for it as well would produce 'aa', no?
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
option explicit private bALT_Down as boolean private lKeyCode as long Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) if keycode = 18 and shift = 4 then bALT_Down = true else if bALT_Down = true then getKey(KeyCode) end if end sub Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer) if keycode = 18 then bALT_Down = false call GetKeyCode end sub private sub getKey(keyCode as long) if keycode >= 96 and keycode <= 105 then lKeyCode = lKeyCode * 10 lKeyCode = lKeyCode + keyCode - 96 end if end sub private sub GetKeyCode() targetcontrol.text = targetcontrol.text + chrw(lKeyCode) end sub
... there is no bug that enough coffee cannot fix...
![]() |
Similar Threads
- Hidden Link - Please help. (PHP)
- Handling KeyPress Event & overriding default keypress events in windows (C++)
- How can i get href="mailto.. to work in a function. (HTML and CSS)
- CAPS LOCK Key (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Saving to another table
- Next Thread: hi
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






