Key input

How many possibilities are there to read the key-input?
I tried to use read() from System.in but I have to press return each time.

Assuming you're making an Applet (or a normal Swing GUI) you could use the KeyListener interface:
import java.applet.*;
import java.awt.event.*;
public class KeyProgram extends Applet implements KeyListener
     public void keyPressed(KeyEvent e)
          int key = e.getKeyCode();
          if (key == KeyEvent.VK_UP)
               //Do something when the up key is pressed
     public void keyTyped(KeyEvent e)
     public void keyReleased(KeyEvent e)
}You can check here for a list of all the key codes: http://java.sun.com/j2se/1.5.0/docs/api/java/awt/event/KeyEvent.html

Similar Messages

  • N900 key input issue

    is there any way to reinstall english-netherlands key input? one stupid app permanently remapped the keys making 3 keys unusable, other ones work, but dont fit my physical keyboard

    do you have a backp of your settings and applications?
    you may need to flash your device to get it back. then when you restore from the backup and it lists the applications, be sure to not let it reinstall the kb mapping app.
    otherwise, there may be a way to --reinstall if we knew what the file name was to do so, if possible.
    cpitchford may know if there is such a file.

  • How to Log terminal output without key input

    Hi all,
    I am trying to log the terminal output with the following command
    script -t -q "/Users/weizixi/Documents/Logs/`date "+%m-%d-%y %H:%M:%S"`"
    however i find that it logs not only the output buy also the key inputs, so how can i log only the output without the keys?
    Thanks/Wei Zixi
    bash-3.2$ less ~/Documents/Logs/01-02-09\ 00\:37\:38
    "/Users/weizixi/Documents/Logs/01-02-09\ 00:37:38" may be a binary file. See it anyway?
    bash-3.2$ scriptreply
    bash: scriptreply: command not found
    bash-3.2$ scriptreplay
    bash: scriptreplay: command not found
    bash-3.2$ more cESC[ESC[K~/do^G^HESC[ESC[KD^Gocuments/lESC[ESC[KLogs/
    /Users/weizixi/Documents/Logs/ is a directory
    bash-3.2$ more ~/Documents/Logs/^G01ESC[ESC[ESC[ESC^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^HESC[1P ~/Documents/Logs^MESC[CESC[C
    ESC[CESC[CESC[CESC[CESC[CESC[CESC[CESC[CESC[CESC[CESC[ESC[1P ~/Documents/Logs^MESC[CESC[CESC[CESC[CESC[CESC[CESC[CESC[
    CESC[CESC[CESC[CESC[ESC[1P ~/Documents/Logs^MESC[CESC[CESC[CESC[CESC[CESC[CESC[CESC[CESC[CESC[CESC[ESC[1P ~/Documents/
    Logs^MESC[CESC[CESC[CESC[CESC[CESC[CESC[CESC[CESC[CESC[Cc ~/Documents/Logs^MESC[CESC[CESC[CESC[CESC[CESC[CESC[CESC[C
    ESC[CESC[CESC[Cd ~/Documents/Logs^MESC[CESC[CESC[CESC[CESC[CESC[CESC[CESC[CESC[CESC[CESC[CESC[C
    bash-3.2$ ls

    How about passing the script output through col ???
    man col
    Only you can determine if col works for you:
    col -b <~/Documents/Logs/01-02-09 00:37:38 >filtered.file
    If that doesn't work, or if it partially works, then the next stop is to maybe write your own script utility, or using something like perl, awk, sed, etc... and do additional post processing of your log file.

  • Set button to accept key input

    Hello,
    I wrote this JSP page that has 4 choices presenting in the button style (A,B,C,D). How do I set its property (or whatever code) so that when a user pressed the letter 'a' on the keyboard it will invoke the same method as when a user click on the A button. I am awared of the AccessKey property, but it requires Alt-A, and I don't want any Alt or Ctrl keys. Please help.

    Hi,
    the answer is that you can't unless you want to put JavaScript on the page that intercepts all keyboard input, calling doClick on the button for every A-D being clicked
    Frank

  • Chinese 10 key input

    I heard that  iPhone users who purchased their devices in china and Hong Kong have received a very nice Chinese input enhancement -- the ten key pinyin input method. It is really painful typing Chinese characters with a 26 key keyboard  on the iPhone due to its small screen size and the lack of adequate input correction features.  Apple May have not noticed that there are many Chinese users overseas who would like to have that feature very much. I am shocked Apple restricted this feature to Chinese and Hong Kong iPhones only. It is really not the Apple way to do this. And Apple would definitely  make their loyal customers disappointed due to this erroneous, if not evil, decision. I am a Verizon customer so even if I bought an iPhone in China or Hong Kong I would not be able to use it on my carrier. Please be good and make this feature available on all iPhones, no matter what the purchase country is.

    I too am very dissapointed of Apple's such decision. I am a Chinese speaker based in Canada and despite that I like iDevices a lot, I've been tortured by the English keyboard when typing Chinese on my iPhone. I'm not even half fast as when I used my Nokia 6630 10 years ago. I have written a feedback on the above link. I hope that it's an error. But it's possible that Apple do this on purpose... if so that'd be even more dissapointing.
    I really hope more people would talk about this so Apple could hear our voice...

  • Shell script that captures key input? (keylogger)

    I want to record all my keystrokes, just to see the frequency of some keys. There is a bunch of keyloggers on google that captures keystrokes, but none that is good and is in the AUR. Isn't it possible to do just with a little shell script? I don't mind if i have to keep the terminal open, and there is no need for any daemon/advanced stuff. Could you record a /dev/something or similar?

    Haha, check this out: (cursor=move, z=fire, q=quit)
    #! /usr/bin/python
    from curses import *
    import threading
    class ckeylog( threading.Thread ):
    def run(self):
    file=open("/dev/input/event1","rb")
    keymap={
    '\x2c': 'z',
    '\x2d': 'x',
    '\x2e': 'c',
    '\xc8': 'UP',
    '\xd0': 'DOWN',
    '\xcb': 'LEFT',
    '\xcd': 'RIGHT',
    '\x10': 'q',
    '\x11': 'w',
    '\x12': 'e',
    '\x01': 'ESC',
    '\x2a': 'LSHIFT',
    '\x1c': 'ENTER',
    self.loop=True
    while self.loop:
    event=file.read(48)
    if event[28] == '\x01':
    state=True
    elif event[28] == '\x00':
    state=False
    else:
    continue
    if event[12] in keymap:
    self.map[keymap[event[12]]]=state
    file.close()
    def quit(self):
    self.loop=False
    keylog=ckeylog()
    keylog.map={}
    keylog.start()
    def main(s):
    curs_set(0)
    ship=[
    "| /\ |",
    "+/!!\+",
    shipx=0
    shipy=0
    bullet="* *"
    bulletx=0
    bullety=0
    fire=False
    while True:
    (my,mx)=s.getmaxyx()
    if 'q' in keylog.map:
    if keylog.map['q']: keylog.quit(); return
    if 'UP' in keylog.map:
    if keylog.map['UP']: shipy=shipy-1
    if 'DOWN' in keylog.map:
    if keylog.map['DOWN']: shipy=shipy+1
    if 'RIGHT' in keylog.map:
    if keylog.map['RIGHT']: shipx=shipx+1
    if 'LEFT' in keylog.map:
    if keylog.map['LEFT']: shipx=shipx-1
    if 'z' in keylog.map:
    if keylog.map['z']: (fire,bullety,bulletx)=(True,shipy,shipx)
    if shipy<0: shipy=0
    if shipy>my-len(ship): shipy=my-len(ship)
    if shipx<0: shipx=0
    if shipx>mx-len(ship[0]): shipx=mx-len(ship[0])
    if fire and bullety == 0: fire=False
    if fire: bullety=bullety-1
    s.erase()
    s.addstr(shipy,shipx,ship[0])
    s.addstr(shipy+1,shipx,ship[1])
    try:
    s.addstr(shipy+2,shipx,ship[2])
    except error: pass
    if fire: s.addstr(bullety,bulletx,bullet)
    s.refresh()
    napms(10)
    wrapper(main)

  • Scanner Input vs. Manually Keyed Input: Is there a way to tell?

    Is there an event, or other evidence, that can be seen in SAP logic debug, that can differentiate whether or not the input was keyed in, or entered from a handheld scanning device? Is there code that will give me this indicator I need to determine?
         Thank-You

    perhaps by create/change userid?  Can everyone scan with handheld device, or just some people, perhaps in a particular department ?

  • Registration Key Input

    Dear All SAP High Technicians.
    I would like to apply the new Registration Key to SQL Anywhere 12 Evaluation Edition.
    Version Info : SQL Anywhere Server Licensing Utility Version 12.0.1.3994
    how can I use the "dblic.exe" command in the CMD?
    dblic.exe -k xxxxxxxxxxx-xxxxxxxxx dbsrv12.lic
    could the above command be valid after obtaining the Registration Key?
    Thank you
    David Park

    Here's a rule of thumb for dblic: It never works first time. Ever.
    Have a look at the examples here: dblic.exe
    Chances are, the full path for the *.lic file is required, along with user name and company. Let the utility tell you what it wants by repeatedly running it and reading the error messages.
    What's the worst that can happen? Probably that you're still stuck with the Developers Edition... hard to imagine making things worse.

  • User Key input for service selection

    Hi, Is there an easy way of transfering keyEvents that are received in the keyPressed(KeyEvent keyEvent) method from a AWT keylistener to the middleware so it does its service selection.
    I'm using the current focussed AWT component method for handling keyevents. Sometimes when the user presses numeric keys I want them to be handled by the middleware, so a service selection happens.
    However my current focussed AWT component "eats" these numeric keys (because of the AWT event mechanism I presume). How can I pass them on or send them back to the middleware?
    An alternative way I thought of was doing a service selection from within my app but if other methods exist I would like to try those first.

    If you are using the MHP, I think you can also receive the event that your focus owner are receiving by using the addUserEventListener(UserEventListener listener,UserEventRepository userEvents) of the org.dvb.EventManager class. If you don't want your focused component to listen to this event, you can use the addUserEventListener(UserEventListener listener,ResourceClient client, UserEventRepository userEvents) method of the same class.
    Let me know if it was what you were looking for.
    Best regards,

  • How can a Backgroundprogram(non focused) recognise key inputs

    Please help me to solve the following problem!!
    I want to have a java program which is able to work with keyboard inputs
    although it isn't focused.
    For example you start this program and another application(which is focused). The program running in the background is able to work with keyboard inputs.
    I imagined to use the Java KeyListener but it only runs on focused applications.
    Please post what I can use instaed....
    Thx for your help

    g
    you think I'll use the program for security breaches???
    No no I imagined to use it for security!!!
    I thought to write a program which runs in the background of school pc's which are free to use for everyone and wanted to stop the program with a java app if words are typed which are not allowed on these pc's. That would make it quiet impossible to get on forbidden internet sites.
    But I see that it isn't possible to develop such a program in java. Maybe that's right that this isn't possible.....

  • [Solved] Key input stops working in urxvt in Openbox

    For you who use the Openbox window manager and the urxvt terminal emulator, does your keyboard sometimes just kinda stop working in urxvt?
    For example, in urxvt, type "openbox --reconfigure". Your keyboard stopped working, didn't it? "Alt-Tab" to another window and then back again. Typing in the urxvt windows works again!
    Another example, load a urxvt window. Now go to a TTY (Ctrl-Alt-F2). Now go back to X. The same problem! No more keyboard input in urxvt!
    This is a really minor bug. But seeing how Openbox is the most popular floating window manager and urxvt is the most popular terminal emulator for Arch Linux users, I can't believe that I'm the only one that noticed this...
    Is there a way to fix this, so urxvt doesn't lose keyboard input?
    Last edited by drcouzelis (2013-03-01 06:07:59)

    Thanks for trying it out.
    Here is my .Xdefaults file:
    URxvt*iconFile: /usr/share/icons/Faience/apps/96/terminal.png
    URxvt*scrollBar: false
    URxvt*termName: screen-256color
    URxvt*saveLines: 10000
    URxvt*cursorBlink: true
    URxvt*pointerBlank: true
    URxvt*pointerBlankDelay: 987654321
    URxvt*font: xft:Terminus:size=12
    URxvt*perl-ext-common: default,fullscreen
    URxvt*keysym.F11: perl:fullscreen:switch
    URxvt*background: #0f0f0f
    URxvt*foreground: #c8c8c8
    URxvt*color0: #251f1f
    URxvt*color1: #eb4509
    URxvt*color2: #94e76b
    URxvt*color3: #ffac18
    URxvt*color4: #46aede
    URxvt*color5: #e32c57
    URxvt*color6: #d6dbac
    URxvt*color7: #efefef
    URxvt*color8: #5e5e5e
    URxvt*color9: #eb4509
    URxvt*color10: #95e76b
    URxvt*color11: #ffac18
    URxvt*color12: #46aede
    URxvt*color13: #e32c57
    URxvt*color14: #d6dbac
    URxvt*color15: #efefef
    I'm currently using the "rxvt-unicode-patched-left_ptr-unicode3" package, but I experienced the same problem with the official "rxvt-unicode" package.
    As I expected, it sounds like the problem is just me... Maybe I can try creating a new user and slowly adding in my personal config files until urxvt breaks.

  • Function Key Input capture

    How do I capture and test for a function key (F2) with a script? I do not want to use the "shortcut key" method with the GUI for a reason.
    thanks,
    Ed

    Mac OS X keyboard shortcuts
    These are the only pre-configured shortcuts for OS X. Been the same forever. I'm not familiar with a function key that "cleared the Desktop." I'm not even sure I know what you mean by that. Perhaps you used some third-party utility.

  • WPA key input

    Is there a way to setup a flash drive to allow guests to use my network instead of providing the WPA key to them and having them use that key to manually log on?

    not possible...

  • Captivate 4 not registering key input when recording a Virtual PC

    I run Windows 7 64 bit with Windows Virtual PC running. I am trying to capture a session using a Windows 7 PC emulated machine, but as soon as I start recording and click inside the Virtual PC window, Captivate 4 no longer register any mouse or keyboard click I make.
    The odd thing, my Colleage is able to make the exact same thing work on his machine, also running Windows 7 64-bit. But for some reason I cannot. What good suggestions are there to allow Captivate 4 to "see" keystrokes when running a Windows Virtual PC?

    Hi there
    Have you tried what is on the page linked below?
    Click here to visit the page
    Cheers... Rick
    Click here for Adobe Authorized Captivate and RoboHelp HTML Training
    Click here for the SorcerStone Blog
    Click here for RoboHelp and Captivate eBooks

  • System Commands from a Single Key Input

    I'm attempting to create a function which will run in the background of a Windows OS and will print the current window from a single keystroke. I want to use HookDll to do so, but have been unsuccessful in opening this file and viewing meaningful results.
    Any direction for the best approach to this problem is appreciated. However, my curiosity (and frustration) has been aroused over HookDll, so I would like to know how to decompile/recompile this file as well.
    I have tried using .Net Reflector, but it returns that HookDll.dll is not a .NET module. I have also used Hex Editor Neo to view the binary file and attempt to make sense of it.

    I'm attempting to create a function which will run in the background of a Windows OS and will print the current window from a single keystroke. I want to use HookDll to do so, but have been unsuccessful in opening this file and viewing meaningful results.
    Any direction for the best approach to this problem is appreciated. However, my curiosity (and frustration) has been aroused over HookDll, so I would like to know how to decompile/recompile this file as well.
    I have tried using .Net Reflector, but it returns that HookDll.dll is not a .NET module. I have also used Hex Editor Neo to view the binary file and attempt to make sense of it.
    Not a scripting issue.
    There are dozens of utilities that can be downloaded that do this.
    Consider using Alt-PrtScr which prints the current Window with a single keystroke:
    http://windows.microsoft.com/en-us/windows/take-screen-capture-print-screen#take-screen-capture-print-screen=windows-8
    ¯\_(ツ)_/¯

Maybe you are looking for