Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: application in java to have the key code

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default application in java to have the key code

    hello everbody,

    i'm bignner in java dev, i need a java application that when i press a key mainly F1,F2 .... return the keycode without using swing just by console.

    thank you very much


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: application in java to have the key code

    Welcome blacksadangel

    Post what you have done/tried so far and explain a little about where you are stuck or ask some questions that would get you back on track.
    Alternatively you can search with keywords like "Java keyboard listener" and most likely find something useful

  3. #3
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: application in java to have the key code

    It's not possible in pure Java. You'll need to use some native code to accomplish this. For example, Here's a post I made on how to accomplish this on Windows.

    Alternatively, you can use the Java Native Access (JNA) library which has a utility which allows you to check the key state "on-demand".

  4. #4
    Junior Member
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: application in java to have the key code

    thank you for yours response
    for example when i press f1,the application show message "f1 pressed" i find a java swing that work fine,but for my case i want just worked in console.
    thank you

Similar Threads

  1. [SOLVED] restricting a particular key stroke or key code
    By chronoz13 in forum AWT / Java Swing
    Replies: 2
    Last Post: April 22nd, 2011, 11:19 AM
  2. how to run any installed application through my java application??
    By sgsamanthjain in forum Java Theory & Questions
    Replies: 1
    Last Post: April 1st, 2011, 08:17 AM
  3. Replies: 0
    Last Post: December 3rd, 2009, 04:43 PM
  4. Java application using C++.Also provide some links and sample code
    By jazz2k8 in forum Java Native Interface
    Replies: 5
    Last Post: July 23rd, 2008, 06:01 AM

Tags for this Thread