How would I... ?
Moderator: General Moderators
How would I... ?
Just curious if anyone knows how I would make text print out when I hold a spacific key and remove it when I release.
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
Ok I got this to work so far except...
- how to make it work when a spacific key is pressed
- and how to make it so it comes up in the right spot when I scroll down on the page
(and doesn't pop-up off the screen where I can't see it)
Is that something with the Y direction maybe? (I really dont know) Please help...
- how to make it work when a spacific key is pressed
- and how to make it so it comes up in the right spot when I scroll down on the page
(and doesn't pop-up off the screen where I can't see it)
Is that something with the Y direction maybe? (I really dont know) Please help...
Code: Select all
<script language="e;Javascript"e;>
<!--
function toggleDiv(id,flagit) {
if (flagit=="e;1"e;)
{
if (document.layers) document.layersї''+id+''].visibility = "e;show"e;
else if (document.all) document.allї''+id+''].style.visibility = "e;visible"e;
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "e;visible"e;
}
if (flagit=="e;0"e;)
{
if (document.layers) document.layersї''+id+''].visibility = "e;hide"e;
else if (document.all) document.allї''+id+''].style.visibility = "e;hidden"e;
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "e;hidden"e;
}
}
function ViewData(user,ValueShow)
{
if(user.style.visibility==ValueShow)return true
var mousex = window.event.x; // mouse location capture event
var mousey = window.event.y; // mouse location capture event
user.style.visibility = ValueShow; // show or hide respective Example
user.style.left = mousex - 50; // place popup at the mouse X (left) location
user.style.top = mousey; // place popup at the mouse Y (top) location
}
//-->
</script>
<style>
#example1 {
position:absolute;
width:150px;
height:100px;
color:blue;
text-align:center;
visibility:hidden;
z-index:10;
}
</style>
</head>
<body onKeyDown="e;ViewData(example1,'visible')"e; onKeyUp="e;ViewData(example1,'hidden')"e;>
<div id="e;example1"e;>
This is the menu
</div>
</body>You're going to need an event handler (easy with IE, not so easy with FF).
then check against the event to see which key was pressed (using the key code) and then do stuff accordingly.
ex for IE:
then check against the event to see which key was pressed (using the key code) and then do stuff accordingly.
ex for IE:
Code: Select all
function checkEvt(evt){
if(evt.keyCode == 13 && evt.ctrlKey){
//do stuff
}
}
<span onClick="e;checkEvt(event)"e;>click me</span>