User:Trizek/vector.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin is at User:Trizek/vector.css. |
function keyboardShortcuts() {
var isCtrl = false;
document.onkeyup=function(e) { //l'user relâche la touche ctrl. La variable passe a False
if(e.which == 17) isCtrl=false;
}
document.onkeydown=function(e){
if(e.which == 17) { //l'user appuie sur la touche ctrl. La variable passe a True
isCtrl=true;
return;
}
//gestion des ctrl+lettre que l'on veux ajouter.
if( isCtrl == true ) {
switch (e.which) { //quelle touche a été enfoncée ?
case 66: //b
insertTags("'''", "'''", 'gras');
return false
break;
case 73: //i
insertTags("''", "''", 'italique');
return false
break;
case 76: // l
insertTags('[[', ']]', 'lien interne');
return false
break;
case 77: // m
insertTags('{{', '}}', 'modèle');
return false
break;
case 85: //u
insertTags('<u>', '</u>', 'souligné');
return false
break
}
}
}
return true
}
//la fonction qui gère tous les appel de fonctions (du moins dans mes divers billets :)
//!\ CELA VEUX DIRE QU'IL FAUT FUSIONNER AVEC LA FONCTION main() EXISTANTE, SI VOUS EN AVEZ UNE /!\
function main() {
// [... autres fonctions ... ]
if (mw.config.get('wgAction') == "edit" || mw.config.get('wgAction') == "submit") { //à n'appeller que si en mode edition, sinon c'est inutile
keyboardShortcuts()
}
}
addOnloadHook(main)
//Merci Darkoneko !