Results 1 to 9 of 9

Thread: [RESOLVED] CTRL+SHIFT+N in keydown function

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    272

    Resolved [RESOLVED] CTRL+SHIFT+N in keydown function

    please tell me what is the code for CTRL+SHIFT+N in keydown function
    DONT RUN EXECUTABLE FILES FROM UNKNOWN SOURCES.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: CTRL+SHIFT+N in keydown function

    In the keydown event, look for (Shift = (vbCtrlMask Or vbShiftMask)) and also that KeyCode is vbKeyN.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: CTRL+SHIFT+N in keydown function

    If you mean how dop you detect it then...

    Code:
        Dim ShiftTest As Integer
       ShiftTest = Shift And 7
       Select Case ShiftTest
    '      Case 1 ' or vbShiftMask
    '         Print "You pressed the SHIFT key."
    '      Case 2 ' or vbCtrlMask
    '         Print "You pressed the CTRL key."
    '      Case 4 ' or vbAltMask
    '         Print "You pressed the ALT key."
          Case 3
    '         Print "You pressed both SHIFT and CTRL."
            If KeyCode = vbKeyN Then
             Print "You pressed both SHIFT and CTRL and N."
            End If
    '      Case 5
    '         Print "You pressed both SHIFT and ALT."
    '      Case 6
    '         Print "You pressed both CTRL and ALT."
    '      Case 7
    '         Print "You pressed SHIFT, CTRL, and ALT."
          End Select

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    272

    Re: CTRL+SHIFT+N in keydown function

    hi lavolp thank you:-)
    DONT RUN EXECUTABLE FILES FROM UNKNOWN SOURCES.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    272

    Re: CTRL+SHIFT+N in keydown function

    Thank you MartinLiss
    DONT RUN EXECUTABLE FILES FROM UNKNOWN SOURCES.

  6. #6

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    272

    Re: CTRL+SHIFT+N in keydown function

    I cannot understand ShiftTest = Shift And 7, what is this for
    DONT RUN EXECUTABLE FILES FROM UNKNOWN SOURCES.

  8. #8
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: CTRL+SHIFT+N in keydown function

    From Help.

    The mouse and keyboard events use the shift argument to determine whether the SHIFT, CTRL, and ALT keys are pressed and in what, if any, combination. If the SHIFT key is pressed, shift is 1; if the CTRL key is pressed, shift is 2; and if the ALT key is pressed, shift is 4. To determine combinations of these keys, use the total of their values. For example, if SHIFT and ALT are pressed, shift equals 5 (1 + 4).

    The three least-significant bits in shift correspond to the state of the SHIFT, CTRL, and ALT keys, as shown in Figure 11.5.

    Figure 11.5 How bits represent the state of the SHIFT, CTRL, and ALT keys



    Any or all of the bits in shift can be set, depending on the state of the SHIFT, CTRL, and ALT keys. These values and constants are listed in the following table:

    Binary Value Decimal Value Constant Meaning
    001 1 vbShiftMask The SHIFT key is pressed.
    010 2 vbCtrlMask The CTRL key is pressed.
    100 4 vbAltMask The ALT key is pressed.
    011 3 vbShiftMask + vbCtrlMask The SHIFT and CTRL keys are pressed.
    101 5 vbShiftMask + vbAltMask The SHIFT and ALT keys are pressed.
    110 6 vbCtrlMask + vbAltMask The CTRL and ALT keys are pressed.
    111 7 vbCtrlMask + vbAltMask + vbShiftMask The SHIFT, CTRL, and ALT keys are pressed.


    As with the mouse events' button argument, you can use the If…Then…Else statement or the And operator combined with the Select Case statement to determine whether the SHIFT, CTRL, or ALT keys are being pressed and in what, if any, combination.

  9. #9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width