JAVASCRIPT

 Home  Computers & Internet  Web Programming JAVASCRIPT
What is Javascript?
Javascript Placement
Syntax
Reserved Words
Variables
Data Types
Escaping Characters
Concatenation
Arithmetic Operators
Assignment Operators
Comparison Operators
Boolean Operators
Conditional Operator
If Statements
Else If Statements
If Else Statements
Switch Statements
While Loops
For Loops
Do While Loops
Break Statement
Continue Statement
prompt()
alert()
Date()
Event Handlers
String Object Methods
Math Object Methods
Window Object Methods
Arrays

JAVASCRIPT ONKEYPRESS EVENT

The javascript onkeypress event handler is used to trigger a script or action when a key from the keyword is pressed and released over an element. The onkeypress event calls the action from most elements.

Example:

<a href="#" onkeypress="alert('Jeepers! I\'ve been touched');">Touch this</a>

The above example will output Jeepers! I 've been touched when you press and release a key from your keyboard over the link.

The onkeypress event can also call a function as follows:

<head>

<script type="text/javascript">

function touchme()
{
alert('Jeepers! I\'ve been touched');
}

</script>

</head>

<body>

<a href="#" onkeypress="touchme();">Touch this</a>

DEMO:

Press and release a key on your keyboard whilst on the link below to see the effect.

Touch this

See also:

onload
onunload
onclick
ondblclick
onmousedown
onmouseup
onmouseover
onmousemove
onmouseout
onkeydown
onkeyup
onfocus
onblur
onsubmit
onreset
onselect
onchange


Home | Privacy Policy | Terms Of Use | Contact Us | Work At Home | Online Jobs | Smart Info | Online Jobs | Data Entry Jobs | Paid Surveys | Info | Info | Typing Jobs | Article Archive | Forum Posting Jobs