JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old January 1st, 2006, 10:18 AM
ossinator ossinator is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2005
Posts: 40 ossinator User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 6 h 11 m 12 sec
Reputation Power: 3
Send a message via ICQ to ossinator
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?

Reply With Quote
  #2  
Old February 4th, 2006, 04:19 PM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 956 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 651767 Folding Title: Super Ultimate Folder - Level 2Folding Points: 651767 Folding Title: Super Ultimate Folder - Level 2Folding Points: 651767 Folding Title: Super Ultimate Folder - Level 2Folding Points: 651767 Folding Title: Super Ultimate Folder - Level 2Folding Points: 651767 Folding Title: Super Ultimate Folder - Level 2Folding Points: 651767 Folding Title: Super Ultimate Folder - Level 2Folding Points: 651767 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 8 h 23 m 32 sec
Reputation Power: 4
Send a message via ICQ to Itsacon
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > OnKeyPress events


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway