Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to override the TAB KeyEvent functionality

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

In applets, I have one TextArea.In that I need to override the Tab key functionality with select all content in that text area.

If you press the tab it should select all the content which text area has.

Here I add keylistener to textarea, I am writing like this

public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_TAB) {
textArea.selectAll();
}
}
Then KeyTyped and KeyPressed I didnot write any thing. Here I am getting selection for all content but, in second tab hit the content is replace with empty value.

How to overcome this issue..

Regards,
Krishna
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Here I am getting selection for all content but, in second tab hit the
> content is replace with empty value.

sounds correct to me, what do you want to happen?
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you're not removing the existing listener, the second Tab hit is processed by it. Since the first Tab hit has selected all the text, the existing listener just replaces the current selection with Tab symbol.
    Bookmark Topic Watch Topic
  • New Topic