Solved

keycode for "SHIFT F10" ???

Posted on 2001-07-16
4
3,020 Views
Last Modified: 2010-08-05
Hi,
How Can I check keycode for "SHIFT F10", Please let me know asap. Is there any way to find out the other keyCode also like enter,space baar, ctrl,alt,etc...)
I Know the keycode of shift (16 is it okay), that I have taken from the javascript's window.event.keyCode
its giving keycode for seperate  for shift and F10 individually but it's not ging any value when I am pressing Shift + F10 together.

Thanks

PaHmn
0
Comment
Question by:pahmn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 15

Expert Comment

by:a.marsh
ID: 6287845
This will capture Shift F10 in IE for you:

<html>
<head>
</head>
<body onload="if(window.event){this.focus()}">
<script language="JavaScript">
<!--
function capKey(){
var str = "You've just pressed SHIFT F10";

 if(window.event){
  if(event.shiftKey && event.keyCode == 121){
   alert(str);
  }
}
document.onkeydown=capKey;
//-->
</script>
</body>
</html>
0
 

Author Comment

by:pahmn
ID: 6288187
Great time for response,
I have tried this logic but ctrl is not reaching inside
if(event.shiftKey && event.keyCode == 121){  ...  and this is happening incase of "shift F1,4,6 & 10" , Its working fine for Shift +F2,3,5,7,8,9,11,12.
I thing "shift + F1,4,6,10" are system  defined keys , so please look into this and let me know.

here is my code :

<html>
<head>
</head>
<BODY leftmargin="2" topmargin="2" bgcolor="#CCCC99" onkeyup="checkKey()">
<script language="JavaScript">
<!--

function checkKey(){
var str = "You've just pressed SHIFT F10";

alert(window.event.keyCode);
alert(window.event.shiftKey);

 if(window.event.shiftKey && window.event.keyCode == 121){
  alert(str);

}

}
//-->
</script>
<H3>Test for shift F10</H3>
</body>
</html>

0
 
LVL 15

Accepted Solution

by:
a.marsh earned 30 total points
ID: 6291229
This script should help your further (I found it on the Internet):

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="text/javascript">
  var aK = new Array(2)
  aKClr()

function getKeyCode(state) {
  aK[state] = event.keyCode
}

function aKShow() {
  alert("keyDown "+aK[0]+"\nkeyPress "+aK[1]+"\nkeyUp "+aK[2])
  aKClr()
}

function aKClr() {
  for (var i = 0; i < aK.length; i++) {
    aK[i] = -1
    }
}
</SCRIPT>
</HEAD>

<BODY onLoad="document.all.pcIn.focus();">
Type a key
<INPUT TYPE="text" ID=pcIn MAXLENGTH=1 SIZE=1
  onkeyDown="getKeyCode(0);" onkeyPress="getKeyCode(1);"
  onkeyUp = "getKeyCode(2);aKShow();this.value = '';">
</BODY>
</HTML>

Just make sure the textbox has the focus each time.

As you pointed out above, you'll find some keys won't work as they do special things - but you can work the code out - for example SHIFT F9 works in the script above but SHIFT F10 doesn't - however F!0 comes after F9 which makes it a code of 121 (as F9 is 120).

:o)

Ant
0
 

Author Comment

by:pahmn
ID: 6291686
Marsh,
That is realy a good script to check out the key code but still I was getting the problem with shift + F10, but I have used onkeyDown event for the any button press and I have checked for shift key press by "window.event.shiftKey" and if it returns true I have populated alert. So Its work in this way.

if (window.event.shiftKey){
alert("shiftpass ... tested by hussain");
}

Thanks for coopration.

Pahmn
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question