PDA

View Full Version : Shift Control Value



cute
05-12-2007, 04:34 AM
hi ,

i have a button.in this default value is present.i need to store two values in that.i.e if i press shift key the another value is taken.how to set that using script. for example if press the button in normal mode it will display 'a' if press shift+ button it take value as 'A'. how this can achieve using script.
WHILE PRESSING THS BUTTON WITH SHIFT COMBINATION THE VALUE ALSO DISPLAYED IN bUTTON ALSO. in ' jscheuer1 'ANSWER THE BUTTON DISPLAY VALUE IS NOT CHANGED.SO HELP THIS TOO.
THANKS.

jscheuer1
05-12-2007, 06:33 AM
Like a keyboard key? Try this out:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function isShifted(e){
var e=e? e : window.event;
if(e.keyCode==16)
isShifted.yes=e.type=='keydown'?1:0;
}
document.onkeyup=document.onkeydown=isShifted;

</script>
</head>
<body>
<div><input type="text" id="targ"><br>
<input type="button" value="A" onclick="document.getElementById('targ').value+=isShifted.yes? this.value : this.value.toLowerCase();"></div>
</body>
</html>