Differenze tra le versioni di "Programmazione:Java/Javascript per il controllo del tasto MAIUSC"
Riga 14: | Riga 14: | ||
</code> | </code> | ||
− | + | <code javascript> | |
onkeypress="capsDetect(event);" | onkeypress="capsDetect(event);" | ||
− | + | </code> | |
− | + | <code javascript> | |
<div>Ocio!</div> | <div>Ocio!</div> | ||
<div style="color:black;height:50px">Maiusc attivo</div> | <div style="color:black;height:50px">Maiusc attivo</div> | ||
<button style="width:74;height:20;font-size:10;border:1px outset #ffffff;" onclick="showHide('box2')">Ok</button> | <button style="width:74;height:20;font-size:10;border:1px outset #ffffff;" onclick="showHide('box2')">Ok</button> | ||
</DIV> | </DIV> | ||
+ | </code> | ||
− | + | <code javascript> | |
− | |||
js/jscapslock.js": | js/jscapslock.js": | ||
function capsDetect( e ) { | function capsDetect( e ) { | ||
Riga 53: | Riga 53: | ||
} | } | ||
} | } | ||
− | + | </code> | |
− |
Versione attuale delle 12:02, 5 ott 2009
<script language="JavaScript" src="js/jscapslock.js"></script>
<script type="text/javascript">
function showHide(layerid){
if (document.getElementById(layerid).style.visibility != "hidden"){
document.getElementById(layerid).style.visibility = "hidden"
}
else{
document.getElementById(layerid).style.visibility = "visible"
}
}
</script>
onkeypress="capsDetect(event);"
Ocio!
Maiusc attivo
<button style="width:74;height:20;font-size:10;border:1px outset #ffffff;" onclick="showHide('box2')">Ok</button>
js/jscapslock.js":
function capsDetect( e ) {
if( !e ) { e = window.event; }
if( !e ) { MWJ_say_Caps( false );
return;
}
//premuto il maiusc
var theKey = e.which ? e.which : ( e.keyCode ? e.keyCode : ( e.charCode ? e.charCode : 0 ) );
//premuto il tasto shift
var theShift = e.shiftKey || ( e.modifiers && ( e.modifiers & 4 ) ); //AND
//se maiusc, guarda che non sia premuto lo shife. Se non maiusc, guarda che sia premuto
MWJ_say_Caps( ( theKey > 64 && theKey < 91 && !theShift ) || ( theKey > 96 && theKey < 123 && theShift ) );
}
function MWJ_say_Caps( oC ) {
if( typeof( capsError ) == 'string' ) {
if( oC ) { showHide('box2'); }
} else { capsError( oC ); }
}
function showHide(layerid){
if (document.getElementById(layerid).style.visibility != "hidden"){
document.getElementById(layerid).style.visibility = "hidden"
}
else{
document.getElementById(layerid).style.visibility = "visible"
}
}