Created
May 26, 2012 08:38
-
-
Save AntoineAugusti/2792947 to your computer and use it in GitHub Desktop.
Keyboard shortcuts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Keyboard Shortcuts | |
// Antoine AUGUSTI - [email protected] | |
// Merci à Adrien COURTOIS pour son aide | |
var isG = false; | |
$(document).keydown(function(e) | |
{ | |
if (e.which == 71 || e.keyCode == 71) | |
{ | |
isG = true; // si la touche G a été pressée | |
} | |
}).keyup(function(e) | |
{ | |
if ($('input:focus').length > 0 || $('textarea:focus').length > 0 || isG != true) | |
{ | |
isG = false; // Si on se trouve dans un input, une textarea ou si on n'a pas pressé la touche G, on ne peut pas faire des raccourcis clavier | |
return false; | |
} | |
if (e.keyCode == true) | |
{ | |
var key = e.keyCode; | |
} | |
else | |
{ | |
var key = e.which; | |
} | |
switch (key) // On regarde la deuxième touche pressée par l'utilisateur | |
{ | |
// G + Q | |
case 81: | |
window.location.href = "../admin"; | |
return false; | |
break; | |
// G + A | |
case 65: | |
window.location.href = "../addquote"; | |
return false; | |
break; | |
// G + E | |
case 69: | |
window.location.href = "../editprofile"; | |
return false; | |
break; | |
// G + H | |
case 72: | |
window.location.href = "../"; | |
return false; | |
break; | |
// G + R | |
case 82: | |
window.location.href = "../random"; | |
return false; | |
break; | |
// G + P | |
case 80: | |
window.location.href = "../profile"; | |
return false; | |
break; | |
// G + M | |
case 77: | |
window.location.href = "../members"; | |
return false; | |
break; | |
// G + L | |
case 76: | |
window.location.href = "../?deconnexion"; | |
return false; | |
break; | |
// G + T | |
case 84: | |
window.location.href = "http://teen-quotes.com"; | |
return false; | |
break; | |
// G + K | |
case 75: | |
window.location.href = "http://kotado.fr"; | |
return false; | |
break; | |
} | |
isG = false; // On réinitialise le booléen | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment