Capturing Control + Shift + Enter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vazz

    #1

    Capturing Control + Shift + Enter

    I am trying to capture the key combination "Control + Shift + Enter"
    in a KeyDown event. I am able capture "Control + Enter" using
    (e.KeyCode == Keys.Enter && e.Modifiers == Keys.Control). How do I
    check if there are two Modifiers?
  • Vadim Chekan

    #2
    Re: Capturing Control + Shift + Enter

    Vazz wrote:[color=blue]
    > I am trying to capture the key combination "Control + Shift + Enter"
    > in a KeyDown event. I am able capture "Control + Enter" using
    > (e.KeyCode == Keys.Enter && e.Modifiers == Keys.Control). How do I
    > check if there are two Modifiers?[/color]

    if (e.KeyCode == Keys.Enter && e.Control && e.Shift) {

    }

    Vadim Chekan.

    Comment

    • Tyler Dixon

      #3
      Re: Capturing Control + Shift + Enter

      Vadim Chekan wrote:[color=blue]
      > Vazz wrote:
      >[color=green]
      >> I am trying to capture the key combination "Control + Shift + Enter"
      >> in a KeyDown event. I am able capture "Control + Enter" using
      >> (e.KeyCode == Keys.Enter && e.Modifiers == Keys.Control). How do I
      >> check if there are two Modifiers?[/color]
      >
      >
      > if (e.KeyCode == Keys.Enter && e.Control && e.Shift) {
      >
      > }
      >
      > Vadim Chekan.
      >[/color]

      Doesn't that need to be a bitwise AND?

      if (e.KeyCode == (Keys.Enter & e.Control & e.Shift) )
      {
      }

      Comment

      • Vazz

        #4
        Re: Capturing Control + Shift + Enter

        Thanks guys. Its actually ((e.KeyCode == Keys.Enter) && e.Shift &&
        e.Control). Works now.

        Vazz


        Tyler Dixon <tdixon@telus.n et> wrote in message news:<Utivb.109 592$jy.52160@cl grps13>...[color=blue]
        > Vadim Chekan wrote:[color=green]
        > > Vazz wrote:
        > >[color=darkred]
        > >> I am trying to capture the key combination "Control + Shift + Enter"
        > >> in a KeyDown event. I am able capture "Control + Enter" using
        > >> (e.KeyCode == Keys.Enter && e.Modifiers == Keys.Control). How do I
        > >> check if there are two Modifiers?[/color]
        > >
        > >
        > > if (e.KeyCode == Keys.Enter && e.Control && e.Shift) {
        > >
        > > }
        > >
        > > Vadim Chekan.
        > >[/color]
        >
        > Doesn't that need to be a bitwise AND?
        >
        > if (e.KeyCode == (Keys.Enter & e.Control & e.Shift) )
        > {
        > }[/color]

        Comment

        • Vadim Chekan

          #5
          Re: Capturing Control + Shift + Enter

          Tyler Dixon wrote:
          [color=blue]
          > Doesn't that need to be a bitwise AND?
          >
          > if (e.KeyCode == (Keys.Enter & e.Control & e.Shift) )[/color]

          No!
          "Bitwize AND" of two bool variables (e.Control & e.Shift) it not wise!

          Vadim Chekan.

          Comment

          Working...