Это мой код
<a href="https://www.google.co.in">Google.com</a>
Я хочу, чтобы это было открыто, когда я нажимаю F2 или любую функциональную клавишу...
Вы можете использовать метод onkeydown.
document.onkeydown = function(){
if(window.event && window.event.keyCode == 113)
{
window.location.href = "http://www.yoursite.com"
}
}
Здесь вы можете использовать что-либо вместо 113.F2 - 113, это ascii.F1 - 112, F3 - 114 и так далее.
document.onkeydown = function(){
if(window.event && window.event.keyCode == 113)
{
window.location.href = "http://www.google.com"
}
}
window.location.href = 'https://www.google.co.in';
,
<html>
<head>
<script>
document.addEventListener("keydown", keyDown, false);
function keyDown(e)
{
var keyCode = e.keyCode;
if(keyCode==113) {window.location.href = "http://www.google.com";}
}
</script>
</head>
<body>
<a href="https://www.google.co.in">Google.com</a>
</body>
</html>
Здесь у вас есть реализация ваших требований с помощью jquery: jsfiddle.net/96rLf/2.
Основная часть: jsfiddle.net/96rLf/2. Вы можете использовать jquery
<input type="button" accesskey="?" value="Next Item">
$(window).keydown(function(e) {
switch (e.keyCode) {
case 37: case 38: //key is left or up
if (currImage <= 1) {break;} //if is the first one do nothing
goToPrev(); // function which goes to previous image
return false; //"return false" will avoid further events
case 39: case 40: //key is left or down
if (currImage >= maxImages) {break;} //if is the last one do nothing
goToNext(); // function which goes to next image
return false; //"return false" will avoid further events
}
return; //using "return" other attached events will execute
});