Skip to main content
This forum is closed to new posts and responses. New discussions are now taking place in the IBM Developer Answers forum.
 
developerWorks
AIX and UNIX
Information Mgmt
Lotus
New to Lotus
Products
How to buy
Downloads
Live demos
Technical library
Training
Support
Forums & community
Events
Rational
Tivoli
WebSphere
Java™ technology
Linux
Open source
SOA and Web services
Web development
XML
My developerWorks
About dW
Submit content
Feedback



developerWorks  >  Lotus  >  Forums & community  >  Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum

developerWorks

  

PreviousPrevious NextNext

RE: How Capture KeyCode in Mozilla
Ron Valley 23.Jun.05 08:18 AM a Web browser
Domino Everyplace All Releases All Platforms


Put following things into a editor (maybe Notepad) then save as something.htm and open it in a webbrowser (Mozilla, IE ...) it shows you how to capture KeyEvents for the most webbrowser :-)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Wie überwache ich Tastatur-Events?</title>
<style type="text/css">
#description {
border-color: #9CCEFF;
border-bottom-width: 1px;
border : groove #9CCEFF;
font-size : 0.9em;
letter-spacing : 1px;
padding : 5px;
background-color: #FFCE63;
layer-background-color: #FFCE63;
}
td, th{
margin: 0px;
padding: 1px;
font-size : 0.9em;
letter-spacing : 1px;
background-color: #FFCE9C;
}
input {
font-family: "Courier new", courier, sans-serif;
}
</style>
<script language="JavaScript" type="text/javascript">

function getNamedKey(k){
if(typeof KeyEvent == "undefined") {
return '';
} else{
for( key in KeyEvent ){
if(KeyEvent[key] == k)
return key.substr("DOM_VK_".length)
}
}
}
function keyDown(evt){
var e = evt || window.event;
var objForm=document.test;
var ch='';

if(document.layers){
if(e.which>0)
ch = String.fromCharCode(e.which);
objForm.charCodeD.value = ch + " [" + e.which + "]";
objForm.altDown.value=(e.modifiers==Event.ALT_MASK);
objForm.ctrlDown.value=(e.modifiers==Event.CONTROL_MASK);
objForm.shiftDown.value=(e.modifiers==Event.SHIFT_MASK);
} else if(document.all){
objForm.altDown.value =e.altKey;
objForm.ctrlDown.value =e.ctrlKey;
objForm.shiftDown.value=e.shiftKey;
if(e.keyCode>0)
ch=String.fromCharCode(e.keyCode);
objForm.keyCodeD.value = ch + " [" + e.keyCode+"]";
} else if (document.getElementById){
objForm.altDown.value =e.altKey;
objForm.ctrlDown.value =e.ctrlKey;
objForm.shiftDown.value=e.shiftKey;
if(e.charCode>0)
ch = String.fromCharCode(e.charCode);
objForm.charCodeD.value= ch + " [" + e.charCode + "]";
ch="";
if(e.which>0)
ch = String.fromCharCode(e.which);
objForm.whichD.value = ch + " [" + e.which + "]";
ch="";
if(e.keyCode>0)
ch = getNamedKey(e.keyCode);
objForm.keyCodeD.value = ch + " [" + e.keyCode+"]";


} else {
objForm.whichD.value = objForm.keyCodeD.value = objForm.charCodeP = 'not supported';
}
return true;
}
function keyUp(evt){
var e = evt || window.event;
var objForm=document.test;
var ch='';

if(document.layers){
if(e.which>0)
ch = String.fromCharCode(e.which);
objForm.charCodeU.value = ch + " [" + e.which + "]";
objForm.altUp.value=(e.modifiers==Event.ALT_MASK);
objForm.ctrlUp.value=(e.modifiers==Event.CONTROL_MASK);
objForm.shiftUp.value=(e.modifiers==Event.SHIFT_MASK);
} else if(document.all){
objForm.altUp.value =e.altKey;
objForm.ctrlUp.value =e.ctrlKey;
objForm.shiftUp.value=e.shiftKey;
if(e.keyCode>0)
ch=String.fromCharCode(e.keyCode);
objForm.keyCodeU.value = ch + " [" + e.keyCode+"]";
} else if (document.getElementById){
objForm.altUp.value =e.altKey;
objForm.ctrlUp.value =e.ctrlKey;
objForm.shiftUp.value=e.shiftKey;
if(e.charCode>0)
ch = String.fromCharCode(e.charCode);
objForm.charCodeU.value= ch + " [" + e.charCode + "]";
ch="";
if(e.which>0)
ch = String.fromCharCode(e.which);
objForm.whichU.value = ch + " [" + e.which + "]";
ch="";
if(e.keyCode>0)
ch = getNamedKey(e.keyCode);
objForm.keyCodeU.value = ch + " [" + e.keyCode+"]";


} else {
objForm.whichU.value = objForm.keyCodeU.value = objForm.charCodeP = 'not supported';
}
return true;
}
function keyPressed(evt){
var e = evt || window.event;
var objForm=document.test;
var ch='';

if(document.layers){
if(e.which>0)
ch = String.fromCharCode(e.which);
objForm.charCodeP.value = ch + " [" + e.which + "]";
objForm.altPressed.value=(e.modifiers==Event.ALT_MASK);
objForm.ctrlPressed.value=(e.modifiers==Event.CONTROL_MASK);
objForm.shiftPressed.value=(e.modifiers==Event.SHIFT_MASK);
} else if(document.all){
objForm.altPressed.value =e.altKey;
objForm.ctrlPressed.value =e.ctrlKey;
objForm.shiftPressed.value=e.shiftKey;
if(e.keyCode>0)
ch=String.fromCharCode(e.keyCode);
objForm.keyCodeP.value = ch + " [" + e.keyCode+"]";
} else if (document.getElementById){
objForm.altPressed.value =e.altKey;
objForm.ctrlPressed.value =e.ctrlKey;
objForm.shiftPressed.value=e.shiftKey;
if(e.charCode>0)
ch = String.fromCharCode(e.charCode);
objForm.charCodeP.value= ch + " [" + e.charCode + "]";
ch="";
if(e.which>0)
ch = String.fromCharCode(e.which);
objForm.whichP.value = ch + " [" + e.which + "]";
ch="";
if(e.keyCode>0)
ch = getNamedKey(e.keyCode);
objForm.keyCodeP.value = ch + " [" + e.keyCode+"]";


} else {
objForm.whichP.value = objForm.keyCodeP.value = objForm.charCodeP = 'not supported';
}
return true;
}

function init(){
if(document.captureEvents)
document.captureEvents(Event.KEYDOWN | Event.KEYPRESS | Event.KEYUP);
document.onkeydown = keyDown;
document.onkeyup = keyUp;
document.onkeypress = keyPressed;
}
window.onload=init;
</script>
</head>

<body>
<form name="test" id="test">
<div id="description">
Testen Sie Ihre Tastatur. Die Ergebnisse werden
in den entsprechenden Textfeldern ausgegeben.
</div>
<table>
<tr>
<th>&nbsp;</th>
<th>keypress</th>
<th>keydown</th>
<th>keyup</th>
</tr>
<tr><td>Zeichen [e.keyCode]</td>
<td><input type="text" name="keyCodeP" size=12 readonly></td>
<td><input type="text" name="keyCodeD" size=12 readonly></td>
<td><input type="text" name="keyCodeU" size=12 readonly></td></tr>
<tr><td>Zeichen [e.which]</td>
<td><input type="text" name="whichP" size=12 readonly></td>
<td><input type="text" name="whichD" size=12 readonly></td>
<td><input type="text" name="whichU" size=12 readonly></td></tr>
<tr><td>Zeichen [e.charCode]</td>
<td><input type="text" name="charCodeP" size=12 readonly></td>
<td><input type="text" name="charCodeD" size=12 readonly></td>
<td><input type="text" name="charCodeU" size=12 readonly></td></tr>
<tr><td>ALT</td>
<td><input type="text" name="altPressed" size=12 readonly></td>
<td><input type="text" name="altDown" size=12 readonly></td>
<td><input type="text" name="altUp" size=12 readonly></td></tr>
<tr><td>CTRL</td>
<td><input type="text" name="ctrlPressed" size=12 readonly></td>
<td><input type="text" name="ctrlDown" size=12 readonly></td>
<td><input type="text" name="ctrlUp" size=12 readonly></td></tr>
<tr><td>SHIFT</td>
<td><input type="text" name="shiftPressed" size=12 readonly></td>
<td><input type="text" name="shiftDown" size=12 readonly></td>
<td><input type="text" name="shiftUp" size=12 readonly></td></tr>
</table>
</form>
<div id="eventTest">

</div>

</body>
</html>




How Capture KeyCode in Mozilla (Pawan k Kumar 23.Jun.05)
. . RE: How Capture KeyCode in Mozilla (Pawan k Kumar 23.Jun.05)
. . RE: How Capture KeyCode in Mozilla (Ron Valley 23.Jun.05)


Document Options






  Document options
Print this pagePrint this page

Search this forum

Forum views and search


  Forum views and search
Date (threaded)
Date (flat)
With excerpt
Author
Category
Platform
Release
Advanced search

Member Tools


RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS
More Lotus RSS feeds

Resources

 Resources
Forum use and etiquette
Native Notes Access
Web site Feedback

Lotus Support

 Lotus Support
IBM Support Portal - Lotus software
Lotus Support documents
Lotus support by product
Lotus support downloads
Lotus support RSS feeds

Wikis

 Wikis
IBM Composite Applications
IBM Mashup Center
IBM Connections
IBM Connections Cloud Developers
IBM Docs
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud for Social Business
IBM Web Experience Factory
Lotus Domino
Lotus Domino Designer
Lotus Expeditor
Lotus Foundations
Lotus iNotes
Lotus Instructor Community Courseware
Lotus Notes
Lotus Notes & Domino Application Development
Lotus Notes Traveler
Lotus Protector
Lotus Quickr
Lotus Symphony
IBM Web Content Manager
WebSphere Portal

Lotus Forums


 Lotus Forums
Notes/Domino 9.0
Notes/Domino 8.5 + Traveler
Notes/Domino XPages development forum
Notes/Domino 8
Notes/Domino 6 and 7
IBM Connections
IBM Mobile Connect
IBM Sametime
IBM SmartCloud Notes
Lotus Enterprise Integration
Lotus Protector
Lotus Quickr
Lotus SmartSuite