Alt+some key in KeyPress event

Reply

Join Date: Dec 2008
Posts: 14
Reputation: yuleball is an unknown quantity at this point 
Solved Threads: 0
yuleball yuleball is offline Offline
Newbie Poster

Alt+some key in KeyPress event

 
0
  #1
Jan 1st, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Alt+some key in KeyPress event

 
0
  #2
Jan 1st, 2009
use sendkeys or API Function.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Alt+some key in KeyPress event

 
0
  #3
Jan 1st, 2009
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:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. richtext1.text = richtext1.text & chrw(keycode)
or am I missing what you need?
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 24
Reputation: kain_mcbride is an unknown quantity at this point 
Solved Threads: 3
kain_mcbride's Avatar
kain_mcbride kain_mcbride is offline Offline
Newbie Poster

Re: Alt+some key in KeyPress event

 
0
  #4
Jan 13th, 2009
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?

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. option explicit
  2. private bALT_Down as boolean
  3. private lKeyCode as long
  4.  
  5. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  6. if keycode = 18 and shift = 4 then
  7. bALT_Down = true
  8. else
  9. if bALT_Down = true then getKey(KeyCode)
  10. end if
  11. end sub
  12.  
  13. Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
  14. if keycode = 18 then bALT_Down = false
  15. call GetKeyCode
  16. end sub
  17.  
  18. private sub getKey(keyCode as long)
  19. if keycode >= 96 and keycode <= 105 then
  20. lKeyCode = lKeyCode * 10
  21. lKeyCode = lKeyCode + keyCode - 96
  22. end if
  23. end sub
  24.  
  25. private sub GetKeyCode()
  26. targetcontrol.text = targetcontrol.text + chrw(lKeyCode)
  27. end sub
... there is no bug that enough coffee cannot fix...
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 14
Reputation: yuleball is an unknown quantity at this point 
Solved Threads: 0
yuleball yuleball is offline Offline
Newbie Poster

Re: Alt+some key in KeyPress event

 
0
  #5
Jan 23rd, 2009
@kain_mcbride
thnx a lot. my problem has een solved
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Alt+some key in KeyPress event

 
0
  #6
Jan 23rd, 2009
Very good. You can mark the thread as solved now.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC