Results 1 to 4 of 4

Thread: Kep Pressed

  1. #1
    mustachMan is offline Member
    Join Date
    Dec 2009
    Posts
    33
    Rep Power
    0

    Default Kep Pressed

    ^Key*^

    Hello,
    I am trying to write a simple program where i want it to check that if
    the space bar is pressed, then it prints out something. I was thinking it would be "if(keypressed == Spacebar)" but i cant seem to figure it out. I dont want to use Java.awt or a key listener, just be simple.
    Last edited by mustachMan; 02-27-2011 at 10:33 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by mustachMan View Post
    I am trying to write a simple program where i want it to check that if
    the space bar is pressed, then it prints out something. I was thinking it would be "if(keypressed == Spacebar)" but i cant seem to figure it out. I dont want to use Java.awt or a key listener, just be simple.
    Without a GUI library such as Swing, how do you propose to respond to a key?

  3. #3
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    Yeah, the main thread of a non-gui app doesn't respond to events. It'd actually be a lot more work to write something to do that without using Swing.

  4. #4
    mustachMan is offline Member
    Join Date
    Dec 2009
    Posts
    33
    Rep Power
    0

Similar Threads

  1. Unable to capture key pressed :((
    By N00Bie in forum New To Java
    Replies: 20
    Last Post: 02-19-2011, 04:57 PM
  2. Detect the ENTER key being pressed
    By aaronfsimons in forum New To Java
    Replies: 12
    Last Post: 05-16-2009, 08:48 PM
  3. get key pressed
    By prashant in forum Networking
    Replies: 1
    Last Post: 03-26-2009, 09:10 PM
  4. Waiting for a button to be pressed
    By SomeGuyOverThere in forum New To Java
    Replies: 6
    Last Post: 08-21-2008, 09:30 PM
  5. key pressed event
    By kavithas in forum New To Java
    Replies: 7
    Last Post: 12-10-2007, 02:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •