Results 1 to 4 of 4

Thread: = and - key codes ? (GetASyncKeyState)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2012
    Posts
    122

    = and - key codes ? (GetASyncKeyState)

    Hi !
    I have a problem here
    I am making a program with hotkeys, and i need to use those two keys: = and - (those two near Backspace, not on numeric keyboard)
    Those two keys are used as + and -, but i kinda cant find out its key code.When i capture it in KeyPress event, it just shows "=" and "-" not the actual Keys.Key value
    At start i thought its Add and Subtract, but those are those keys on numeric keyboard, and not everyone has it.
    Thanks in advance.

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,381

    Re: = and - key codes ? (GetASyncKeyState)

    Well, I cannot find one here, but I can find on ein the ASCII table here. You can also use the CChar("=") or CChar("-")
    Code:
            If e.KeyChar = CChar("=") Then
                MessageBox.Show("=")
            ElseIf e.KeyChar = CChar("-") Then
                MessageBox.Show("-")
            End If
    Not only will that work with the subtract button next to the backspace, but it works on the numeric keypad as well.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

  3. #3
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: = and - key codes ? (GetASyncKeyState)

    You should use KeyDown for hotkeys not KeyPress. Many keys do not trigger a keypress event at all. The two keys are KeyCode.Oemplus and KeyCode.OemMinus.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  4. #4
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,381

    Re: = and - key codes ? (GetASyncKeyState)

    Quote Originally Posted by dunfiddlin View Post
    You should use KeyDown for hotkeys not KeyPress. Many keys do not trigger a keypress event at all. The two keys are KeyCode.Oemplus and KeyCode.OemMinus.
    Ahh, those are the key codes! Oh course you'd know them ;]
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

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