HighDots Forums  

Stampare un carattere al posto di un altro.

Javascript (Italian) Il linguaggio JavaScript (it.comp.lang.javascript)


Discuss Stampare un carattere al posto di un altro. in the Javascript (Italian) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Lupino
 
Posts: n/a

Default Stampare un carattere al posto di un altro. - 10-17-2005 , 04:56 PM






Salve a tutti,
ho la necessità di stampare un carattere quando viene premuto un tasto
corrispondente ad un altro tasto. In particolare, mi servirebbe che la
pressione del punto del tastierino numerico in un input field comporti la
comparsa della virgola.

Ho ricavato il keyCode del tasto (che è 110), ed ho risolto parzialmente
il problema impostando questi handler per il field in questione:

- onkeydown
if(event.keyCode == 110) {
event.target.value = event.target.value + ',';
return false;
}

- onkeyup
if(event.keyCode == 110)
event.target.value = event.target.value.substr(0,
event.target.value.length - 1);
return false;

Ma questo genera un fastidioso effetto "compari-scompari" del punto (come
è evidente dal codice).

Come potrei risolvere il problema in maniera più elegante?

Grazie mille in anticipo,

--
[ Andrea Spadaccini - a.k.a. Lupino/Lupin85 - Catania - ICQ#: 91528290 ]
[ GPG ID: 5D41ABF0 - key @ pgp.mit.edu - Slackware 10.1 w/Linux 2.4.22 ]
[ Linux User # 313388 - MAIL: a.spadaccini(at)catania(dot)linux(dot)it ]


Reply With Quote
  #2  
Old   
Cristiano Larghi
 
Posts: n/a

Default Re: Stampare un carattere al posto di un altro. - 10-18-2005 , 03:43 AM






In data Mon, 17 Oct 2005 20:56:35 GMT, Lupino ha scritto:

Quote:
Salve a tutti,
ho la necessità di stampare un carattere quando viene premuto un tasto
corrispondente ad un altro tasto.
Se non ricordo male se ne è discusso pochi giorni fa.

--
"Run rabbit run
dig that hole, forget the sun
and when at last the work is done
don't sit down, it's time to dig another one"
P.F.


Reply With Quote
  #3  
Old   
Lupino
 
Posts: n/a

Default Re: Stampare un carattere al posto di un altro. - 10-18-2005 , 01:52 PM



On Tue, 18 Oct 2005 09:43:14 +0200, Cristiano Larghi wrote:

Quote:
Se non ricordo male se ne è discusso pochi giorni fa.
Hai ragione, scusami. Non ci avevo fatto caso.

--
[ Andrea Spadaccini - a.k.a. Lupino/Lupin85 - Catania - ICQ#: 91528290 ]
[ GPG ID: 5D41ABF0 - key @ pgp.mit.edu - Slackware 10.1 w/Linux 2.4.22 ]
[ Linux User # 313388 - MAIL: a.spadaccini(at)catania(dot)linux(dot)it ]



Reply With Quote
Reply




Thread Tools
Display Modes

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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.