Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / September 2006

Tip: Looking for answers? Try searching our database.

Backspace

Thread view: 
freesoft_2000 - 07 Sep 2006 20:17 GMT
Hi everyone,

            Does anyone know how do i detect that the backspace button
has been pressed by using the keylistener. What i mean is what do i put in
the keypressed method to know that the backspace button has been pressed?

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
Oliver Wong - 07 Sep 2006 20:22 GMT
>             Does anyone know how do i detect that the backspace button
> has been pressed by using the keylistener. What i mean is what do i put in
> the keypressed method to know that the backspace button has been pressed?

   The same way you'd detect any other key event. Just register a listener
for the event, and when a keyPressed() event occurs, examine the event to
see if it involved the backspace key. The virtual key code for backspace is
VK_BACK_SPACE.
(http://java.sun.com/j2se/1.5.0/docs/api/java/awt/event/KeyEvent.html#VK_BACK_SPACE)

   - Oliver
mikeboggs - 08 Sep 2006 03:30 GMT
I believe you will be able to do this:

public void keyPressed(KeyEvent e)
{
    if (e.getKeyCode()==e.VK_BACK_SPACE)
    {
          //do what you need to do
    }
}

Should also work with VK_ENTER, VK_TAB as well, just for reference.

Hope this helps.

Michael Boggs


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.