Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   How To: Make Keyboard Keys To Execute A Method? (http://www.velocityreviews.com/forums/t951919-how-to-make-keyboard-keys-to-execute-a-method.html)

clusardi2k@aol.com 09-07-2012 12:10 PM

How To: Make Keyboard Keys To Execute A Method?
 
Hello,

How do I get a sequence of keyboard keys to execute a method.

For example, if someone types the "control" key, "shift" key, and the "enter" key I want to execute a method called "keyboard_input". Do you also have a working example.

Thank you,

John B. Matthews 09-07-2012 01:47 PM

Re: How To: Make Keyboard Keys To Execute A Method?
 
In article <860b8b1f-3b08-4cde-8473-16cd910a54af@googlegroups.com>,
clusardi2k@aol.com wrote:

> How do I get a sequence of keyboard keys to execute a method.
>
> For example, if someone types the "control" key, "shift" key, and the
> "enter" key I want to execute a method called "keyboard_input". Do
> you also have a working example.


See How to Use Key Bindings:

<http://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html>
<http://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html#eg>

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

clusardi2k@aol.com 09-07-2012 04:10 PM

Re: How To: Make Keyboard Keys To Execute A Method?
 


http://docs.oracle.com/javase/tutori...EventDemo.java

John B. Matthews 09-07-2012 05:15 PM

Re: How To: Make Keyboard Keys To Execute A Method?
 
In article <9396fa63-f5c0-4f1b-a761-e6494971cafd@googlegroups.com>,
clusardi2k@aol.com wrote:

> > How do I get a sequence of keyboard keys to execute a method.
> >
> > For example, if someone types the "control" key, "shift" key, and
> > the "enter" key I want to execute a method called "keyboard_input".
> > Do you also have a working example.


To which I replied,

> See How to Use Key Bindings:
>
> <http://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html>
> <http://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html#eg>


To which you replied,

> <http://docs.oracle.com/javase/tutorial/uiswing/examples/events/KeyEventDemoProject/src/events/KeyEventDemo.java>


KeyListener is fairly low-level; it might be appropriate for "a
sequence of keyboard keys." The rest of your question mentions keys
used as modifiers, for which key bindings are considerably more
convenient.

See also, How to Use Actions:

<http://docs.oracle.com/javase/tutorial/uiswing/misc/action.html>

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

Roedy Green 09-08-2012 05:28 AM

Re: How To: Make Keyboard Keys To Execute A Method?
 
On Fri, 7 Sep 2012 05:10:46 -0700 (PDT), clusardi2k@aol.com wrote,
quoted or indirectly quoted someone who said :

>For example, if someone types the "control" key,

"shift" key, and the "enter" key I want to execute a method called
"keyboard_input". Do you also have a working example.

See http://mindprod.com/jgloss/jmenu.html

the easiest way is to make the keys accelerator shortcuts for a menu.
--
Roedy Green Canadian Mind Products http://mindprod.com
A new scientific truth does not triumph by convincing its opponents and making them see the light,
but rather because its opponents eventually die, and a new generation grows up that is familiar with it.
~ Max Planck 1858-04-23 1947-10-04




All times are GMT. The time now is 04:08 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.