Results 1 to 3 of 3

Thread: [RESOLVED] [2005] How To Detect In KeyPress Ctrl+Enter?

  1. #1

    Thread Starter
    Addicted Member GedOfEarthsea's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    145

    Resolved [RESOLVED] [2005] How To Detect In KeyPress Ctrl+Enter?

    Hello, I just downloaded C# 2005 Express last night to try it out and I liked it, so I started a project with it. I just have a quick question. How would I, in the KeyPress event of a textbox see if the use pressed the Enter key as they were holding Ctrl, like in Internet Explorer you can type google, then hold Ctrl and press Enter it will change it to http://www.google.com/ and navigate to it. That is what I want to do with my web browser project. I just don't know how to detect if ctr is being held down in the textbox.

    Thanks

  2. #2

    Thread Starter
    Addicted Member GedOfEarthsea's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    145

    Re: [2005] How To Detect In KeyPress Ctrl+Enter?

    Nevermind, I figured it out. I guess you can't do it in KeyPress, but in KeyDown you can use modifiers.

    Thanks

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] How To Detect In KeyPress Ctrl+Enter?

    It's important to understand the difference between the purposes of the KeyDown and KeyUp events compared to the KeyPress event.

    The KeyDown and KeyUp events correspond to keys on the keyboard being depressed and released, while the KeyPress event corresponds to a character being entered in a control. For example, if you press the C key on the keyboard you'll get a KeyDown event for the Keys.C key, a KeyPress event for the "c" character (lower case), then a KeyUp event for the Keys.C key. In contrast if you press the Shift+C key combination you'll get one KeyDown event for Keys.Shift and one KeyDown event for Keys.C, followed by on KeyPress event for "C" (upper case), followed by one KeyUp event for Keys.Shift and one KeyUp event for Keys.C.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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