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 / C++ / MFC
  4. read keyboard keys

read keyboard keys

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorial
4 Posts 4 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.
  • D Offline
    D Offline
    deeps_cute
    wrote on last edited by
    #1

    hi i have to read the keys pressed in keyboard and send that to a drive. how to receve the keys pressed using vc++. pls help me

    Arise Awake Stop Not Till ur Goal is Reached.

    P J H 3 Replies Last reply
    0
    • D deeps_cute

      hi i have to read the keys pressed in keyboard and send that to a drive. how to receve the keys pressed using vc++. pls help me

      Arise Awake Stop Not Till ur Goal is Reached.

      P Offline
      P Offline
      Programm3r
      wrote on last edited by
      #2

      Hi, If I understand your question correctly, try using one of these _getch, _getche Get a character from the console without echo (_getch) or with echo (_getche). int _getch( void ); int _getche( void ); Example/* GETCH.C: This program reads characters from * the keyboard until it receives a 'Y' or 'y'. */ #include #include void main( void ) { int ch; _cputs( "Type 'Y' when finished typing keys: " ); do { ch = _getch(); ch = toupper( ch ); } while( ch != 'Y' ); _putch( ch ); _putch( '\r' ); /* Carriage return */ _putch( '\n' ); /* Line feed */ }
      _kbhit Checks the console for keyboard input. int _kbhit( void ); Example/* KBHIT.C: This program loops until the user * presses a key. If _kbhit returns nonzero, a * keystroke is waiting in the buffer. The program * can call _getch or _getche to get the keystroke. */ #include #include void main( void ) { /* Display message until key is pressed. */ while( !_kbhit() ) _cputs( "Hit me!! " ); /* Use _getch to throw key away. */ printf( "\nKey struck was '%c'\n", _getch() ); _getch(); }
      Or have a look at SendKeys in C++[^] Regards,


      The only programmers that are better than C programmers are those who code in 1's and 0's..... :) :)Programm3r My Blog: ^_^

      1 Reply Last reply
      0
      • D deeps_cute

        hi i have to read the keys pressed in keyboard and send that to a drive. how to receve the keys pressed using vc++. pls help me

        Arise Awake Stop Not Till ur Goal is Reached.

        J Offline
        J Offline
        James R Twine
        wrote on last edited by
        #3

        If you want to write a Key Logger, you might want to start by stating so, and searching Google for Key Logger source code.    In the simplest form, you would create a Keyboard Hook (in a DLL), and intercept keyboard events and write them to a file.    In the more robust and professional forms, you use a Window Message Hook and pay attention to keyboard-related and mouse-button-related events so that you can correctly capture user input from several sources (on-screen keyboards, enhanced keypads, buttons that trigger text macros, voice recognition/dictation, mouse gesture systems, Accessibility aids/applications like Dasher[^], etc.)    I believe that far too many so-called "key loggers" are written by amateurs that think that the only way to get a character into an edit control is by pressing a key on a keyboard.  Nothing is worse than bad software masquerading as security.   (Well, maybe except for the companies that use them!)    Peace!

        -=- James
        Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
        Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
        See DeleteFXPFiles

        1 Reply Last reply
        0
        • D deeps_cute

          hi i have to read the keys pressed in keyboard and send that to a drive. how to receve the keys pressed using vc++. pls help me

          Arise Awake Stop Not Till ur Goal is Reached.

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          See Onscreen Keyboard[^] does help?


          WhiteSky


          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