CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 1999
    Location
    Russia
    Posts
    1

    How can I get pressed key in Java like getch() in C or C++

    System.in.read() method give string at one time, and don't give anything until I press Enter. I need something like getch() in C.


  2. #2
    Join Date
    Sep 1999
    Posts
    7

    Re: How can I get pressed key in Java like getch() in C or C++


    Use java.lang.System.in.read() function in try catch block


  3. #3
    Guest

    Re: How can I get pressed key in Java like getch() in C or C++

    If you are not using a DOS environment or such and want to catch key presses in say a windowed application or an applet, you can use the deprecated keyDown() or keyUp() methods. Or, you could implement the KeyListener interface and utilize the keyPressed(), keyReleased(), and keyTyped() methods. Just a thought.


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

Featured