keylistener

How do I have YAHOO.util.KeyListener disabled when an input element is focused?

I have a MenuBar setup with YUI's MenuBar widget, and I have a YAHOO.util.KeyListener attached to 'document' to get quick keyboard access to the menus and submenu items (e.g. 's' to open the Setup menu). The problem is that the keylistener will still fire when a user is in an input element. For example, a user might be typing 'soup' in...

KeyListener in Java is abstract; cannot be instantiated?

Hey all, I am trying to create a Key Listener in java however when I try KeyListener listener = new KeyListener(); Netbeans is telling me that KeyListener is abstract;cannot be instantiated. I know that I am missing some other piece of this key listener, but since this is my first time using a key listener i am unsure of what else i...

Accessing a "nameless" Jbutton in an anonymous class from another anonymous class?

Hey all, alright I know this sounds a little far-fetched, but let me explain. I created 26 JButtons in an anonymous actionListener labeled as each letter of the alphabet. for (int i = 65; i < 91; i++){ final char c = (char)i; final JButton button = new JButton("" + c); alphabetPanel.add(button); butt...

Java KeyListener for JFrame is being unresponsive?

Hey all, I am trying to implement a KeyListener into my JFrame. I have used the following code (at the moment im just trying to get this to work with my JFrame). System.out.println("test"); addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { System.out.println( "tester"); } ...

Dealing with KeyEvents in java.

Say I have a GUI, and I want the program to actually run when the spacebar is pressed, but if the spacebar is pressed again then I want the program to exit. Would something like this work? public class MouseClicker extends JApplet implements KeyListener{ int counter = 0; MouseClicker m1 = new MouseClicker(); //all of the other methods ...

GXT KeyListener.componentKeyDown() immediately closes MessageBox.alert()

In GXT, MessageBox methods are asynchronous, meaning that the application does not "lock up" while the message box is displayed. I using a KeyListener to process enter key presses in a form (to increase usability, i.e., allowing the form to be submitted by the enter key) and subsequently disabling the form fields while the application p...

Java Keylistener without window being open?

I'm trying to create an auto-clicker in Java(only language I know and I just learned Threads). I want to have the applet open in it's own window(not on a webpage), and I want to be able to start and stop the program with the spacebar without the window being selected so that I can use the auto-clicker on another program and be able to st...

Event listener in Java without app having focus? (Global keypress detection)

I've been searching for a while and everybody seems to think this is not possible using just Java, so I'll give SO a shot ;) Is there any way to have my Java application listen for events (key events in particular) while another unrelated application has window focus? In my situation, I'm looking to detect when the user has pressed the ...

Listening for input without focus in Java

I'm making a small program in Java using the Robot class. The program takes over the mouse. while in the course of debugging if it starts acting in a way that I don't want it's hard to quit the program, since I can't move the mouse over to the terminate button in eclipse, and I can't use hotkeys to hit it because the mouse is constant cl...

How do I detect the 'delete' key in my Field subclass?

I'm trying to detect and override the Delete key on the Blackberry keyboard. For some reason, it never makes it inside my case statement as when it hits that point: Keypad.key(keycode) == 8 Keypad.KEY_DELETE == 127 What's my error? public class MyField extends ListField implements KeyListener { // ... /** Implementation of KeyListen...

Catching Tabs in TextArea

Does anyone know a cross-browser, reliable solution for catching presses of the tab-key in a textarea field, and replacing (in the correct position) 4 spaces? The textarea is being used to input an essay, and needs this feature. Note: I tried using FCKEditor, among others, which did not catch tabs and had a bunch of features I didn't n...

How can you check if a key is currently pressed using Tkinter in Python?

Is there any way to detect which keys are currently pressed using Tkinter? I don't want to have to use extra libraries if possible. I can already detect when keys are pressed, but I want to be able to check at any time what keys are pressed down at the moment. ...

stopPropagation not working for KeyListener in YUI 2.7

I have created a new YAHOO.util.KeyListener to attach to a specific element and have also created another new YAHOO.util.KeyListener to attach to the entire document. They are both associated with the "enter" key (keys:13). In the handler function for the listener attached to the specific element, I have the following code: ...

Howto make Java JNI KeyListener with C++

I'm trying to make a program like AutoHotKey, but with a graphical interface. I'm using java.awt.Robot Now I want to make the code for checking the state from a key (In AHK: getKeyState) Of course somthing like a KeyListener without having focus. I read already something with JNI and C++, but.... I can't find some information. Can someb...

KeyListener(KeyPressed) doesn't working

I try to make it like this : Try using a key listener to detect each time the user enters text into the field. Each time the key event is triggered, get the length() of the text in the JTextField. If the length >= limit, then disable editing. However, if the delete key is pressed, remove the last character in the JTextField and setEditab...

Handle callback for ENTER key in GWT-Ext's NumberField

I use GWT-Ext library for building GUI for a webapp. I'd like to process an ENTER key press inside of the NumberField. It should be like this: final NumberField requiredHeight = new NumberField(); requiredHeight.setValue(125); requiredHeight.setAllowBlank(false); requiredHeight.setAllowNegative(false); requiredHeigh...

KeyListener and timing

Hello, I am writing program in Java will have to do with music input. I want to use my computer keyboard as instrument.Pretty much it will be as button accordion which I play. I will do the mapping between keys and notes through 2 octaves for beginning. I was thinking what would be good design in timing how much the key was pressed. I a...

JApplet/JPanel not receiving KeyListener events!

Hello, I cannot get my JPanel within my JApplet to receive keyboard events. I CANNOT FATHOM why! Note that... Clicking the panel (with mouse) before typing makes no difference. This is by far the most common advice I see given on the Net. I have tried using the 'low-level' java.awt.KeyEventDispatcher interface. That makes no differen...

BlackBerry - KeyListener with global scope

Hello all, I am new to BlackBerry App development. I want to be able to listen for keypress events whenever the BlackBerry (8900 in my case) is on and on all screens is this possible? If so, it would be great for someone to direct me in the right direction. I am already having a look at Interface KeyListener. import net.rim.device.ap...

Catching key pressed with the virtual keyboard in Android?

With the physical keyboard you can catch key presses with a KeyListener, something like: myEditText.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { /* do something */ } } }); Does anyone know ...