Key Down Key Press Event Use for Ctrl-d

  • Thread starter Thread starter Ed Bitzer
  • Start date Start date
E

Ed Bitzer

Can't master the keypress and keydown events to pick up the combination
Ctrl + d. If I use the KeyDown even to pick up the Ctrl key
(intCtrlDown = (Shift And ac CtrlMask) >0 which it will<g> how do I use
this bit of information to pick up "d" (ASCI 100 for the lower case)
pressed in combination. There certainly is extensive information on the
subjects in the Help file but I need some spoon feeding.

Ed
 
how about a MsgBox(keycode) inside the keyDown event? You can then check
what happens if/when you press d, or whatever-d
 
Well it was not enough push<g>. I suspect I may be interpreting
improperly but I don't want to have to respond to a message box - but I
understand there are other messages running around that can be picked
up - but just now sure what you mean.

Ed
 
Persistence paid off - the KeyPress event did the job:
Private Sub Form_KeyPress(KeyAscii As Integer)
Const CTRL_d_CODE = 4 '4 is the ASCII code generated by Ctrl + d
Dim num
If KeyAscii = CTRL_d_CODE Then

Ed
 
The general purpose solution is to sense the state of the Ctrl, Shift & Alt
keys in keyDown, save those in boolean global variables (ugh), then use
those globals in KeyPress. Then you can trap any weird combination you want.
Many such combinations do not have distinct KeyPress values.

HTH,
TC
 
TC,

Sort of suspected that from reading the help files - but did not know
how to handle. I too try to avoid global but I see how that would work
and of course you would have to turn on and off. Will put away with my
myriad of code snips. I use a program called askSam (a free from
database) to same bits and pieces of everything and anything - it has
numerous methods of locating but of course they still get lost<g>.

Ed
 
B.C.B,

Got it - sorry I did not pick up on. As you see I stumbled upon a
method and now TC notes an even more flexible.

Ed
 
Back
Top