|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
OnKeyPress events
Hello.
I'm trying to write a Script to substitute keys pressed while having a text box focused with other keys - my idea is to enable writing in my native language with a us keyboard. My problem is that i have no idea how to actually substitute the keys pressed - what i figured as an idea was to register OnKeyPress events and depending on the key pressed to substitute it with the correct one. Problem is, that i can't think of any efficient way of telling the browser not to write the letter that was pressed - anyone having any ideas? |
|
#2
|
||||
|
||||
|
Keep a seperate Javascript variable where you keep the string with the translated keys.
After each keypress, add the translated key to the variable, and then REPLACE the entire text-box value with the value of the variable. Behaviour may differ on a per-browser basis though, as some browsers alter the text box before the keypress event, and some do it before. Alternatively, you could simply add a second, read-only box, where the translated text is shown, and leave the original input as-is.
__________________
This is my code. Is it not nifty? "The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools." ---Douglas Adams Join the Itsacon fanclub! Zero Tolerance: Spammers banned so far: 264
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > OnKeyPress events |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|