Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Capturing Cursor Keys?

Capturing Cursor Keys?

Scheduled Pinned Locked Moved C#
c++question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zombies with Coffee LLC
    wrote on last edited by
    #1

    I'm stumped. (I really am a decent MFC programmer, seriously...) I'm writing a control to move an image around. If I override KeyDown, I can capture absolutely EVERYTHING except for the four cursor keys. Everything else is captured, shift, control, insert, home, pgup, 'A', etc... private void Afix_KeyDown( object sender, KeyEventArgs e ) { switch( e.KeyCode ) { case Keys.Up: ...; break; case Keys.Down: ...; break; } } What am I doing wrong on the cursor keys?! Thanks guys!

    J 1 Reply Last reply
    0
    • Z Zombies with Coffee LLC

      I'm stumped. (I really am a decent MFC programmer, seriously...) I'm writing a control to move an image around. If I override KeyDown, I can capture absolutely EVERYTHING except for the four cursor keys. Everything else is captured, shift, control, insert, home, pgup, 'A', etc... private void Afix_KeyDown( object sender, KeyEventArgs e ) { switch( e.KeyCode ) { case Keys.Up: ...; break; case Keys.Down: ...; break; } } What am I doing wrong on the cursor keys?! Thanks guys!

      J Offline
      J Offline
      James T Johnson
      wrote on last edited by
      #2

      You need to override the form's IsInputKey method to tell it that the cursor keys are to be handled as input. HTH, James Sonork ID: 100.11138 - Hasaki "I left there in the morning with their God tucked underneath my arm their half-assed smiles and the book of rules. So I asked this God a question and by way of firm reply, He said - I'm not the kind you have to wind up on Sundays." "Wind Up" from Aqualung, Jethro Tull 1971

      Z 1 Reply Last reply
      0
      • J James T Johnson

        You need to override the form's IsInputKey method to tell it that the cursor keys are to be handled as input. HTH, James Sonork ID: 100.11138 - Hasaki "I left there in the morning with their God tucked underneath my arm their half-assed smiles and the book of rules. So I asked this God a question and by way of firm reply, He said - I'm not the kind you have to wind up on Sundays." "Wind Up" from Aqualung, Jethro Tull 1971

        Z Offline
        Z Offline
        Zombies with Coffee LLC
        wrote on last edited by
        #3

        Thanks James. Works great now. Here's the code I used to override IsInputKey protected override bool IsInputKey( Keys keyData ) { bool bIsInputKey = true; switch( keyData ) { case Keys.Left: break; case Keys.Right: break; case Keys.Down: break; case Keys.Up: break; default: bIsInputKey = base.IsInputKey( keyData ); break; } return bIsInputKey; }

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups