Solved

keycode for "SHIFT F10" ???

Posted on 2001-07-16
4
2,922 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now