Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

keycode for "SHIFT F10" ???

Posted on 2001-07-16
4
Medium Priority
?
3,133 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
  • 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 120 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
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…
Suggested Courses

580 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