| 👁 Image | This is the module sandbox page for Module:Key (diff). |
| 👁 Warning | This Lua module is used in MediaWiki:Clearyourcache, and on approximately 4,800 pages. Changes to it can cause immediate changes to the Wikipedia user interface. To avoid major disruption, any changes should be tested in the module's or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Please discuss changes on the talk page before implementing them. |
| 👁 CSS | This module uses TemplateStyles: |
Implements {{key press}}
localp={} localkey_labels={ -- Control keys ['backspace']='← Backspace', ['caps lock']='⇪ Caps Lock', ['cmd']='⌘ Cmd', ['command']='⌘ Command', ['enter']='↵ Enter', ['hyper']='✦ Hyper', ['menu']='≣ Menu', ['meta']='◆ Meta', ['opt']='⌥ Opt', ['option']='⌥ Option', ['shift']='⇧ Shift', ['tab']='Tab ↹', ['super']='❖ Super', ['win']='⊞ Win', ['[[alt]]']='[[Alt key|Alt]]', ['[[altgr]]']='[[AltGr key|AltGr]]', ['[[backspace]]']='← [[Backspace]]', ['[[caps lock]]']='⇪ [[Caps Lock]]', ['[[cmd]]']='⌘ [[Command key|Cmd]]', ['[[command]]']='⌘ [[Command key|Command]]', ['[[delete]]']='[[Delete key|Delete]]', ['[[end]]']='[[End key|End]]', ['[[enter]]']='↵ [[Enter key|Enter]]', ['[[esc]]']='[[Esc key|Escape]]', ['[[escape]]']='[[Esc key|Esc]]', ['[[fn]]']='[[Fn key|Fn]]', ['[[home]]']='[[Home key|Home]]', ['[[hyper]]']='✦ [[Hyper key|Hyper]]', ['[[insert]]']='[[Insert key|Insert]]', ['[[menu]]']='≣ [[Menu key|Menu]]', ['[[meta]]']='◆ [[Meta key|Meta]]', ['[[opt]]']='⌥ [[Option key|Opt]]', ['[[option]]']='⌥ [[Option key|Option]]', ['[[page down]]']='[[Page Up and Page Down keys|Page Down]]', ['[[page up]]']='[[Page Up and Page Down keys|Page Up]]', ['[[pgdn]]']='[[Page Up and Page Down keys|PgDn]]', ['[[pgup]]']='[[Page Up and Page Down keys|PgUp]]', ['[[print screen]]']='[[Print Screen]]', ['[[prt sc]]']='[[Print Screen|Prt Sc]]', ['[[return]]']='↵ [[Enter key|Return]]', ['[[scrlk]]']='[[Scroll Lock|ScrLk]]', ['[[scroll lock]]']='[[Scroll Lock]]', ['[[shift]]']='⇧ [[Shift key|Shift]]', ['[[super]]']='❖ [[Super key (keyboard button)|Super]]', ['[[tab]]']='[[Tab key|Tab]] ↹', ['[[win]]']='⊞ [[Windows key|Win]]', ['[[windows]]']='⊞ [[Windows key|Windows]]', -- Arrow keys ['up']='↑', ['down']='↓', ['left']='←', ['right']='→', ['[[up]]']='[[Arrow key|↑]]', ['[[down]]']='[[Arrow key|↓]]', ['[[left]]']='[[Arrow key|←]]', ['[[right]]']='[[Arrow key|→]]', -- Characters ['asterisk']='*', ['hash']='#', ['colon']=':', ['pipe']='|', ['semicolon']=';', ['equals']='=', -- Left & right analog sticks. ['l up']='L↑', ['l down']='L↓', ['l left']='L←', ['l right']='L→', ['l ne']='L↗', ['l se']='L↘', ['l nw']='L↖', ['l sw']='L↙', ['r up']='R↑', ['r down']='R↓', ['r left']='R←', ['r right']='R→', ['r ne']='R↗', ['r se']='R↘', ['r nw']='R↖', ['r sw']='R↙', -- PlayStation keys ['ex']='×', ['circle']='○', ['square']='□', ['triangle']='△', -- Nintendo 64 and GameCube keys ['c up']='C↑', ['c down']='C↓', ['c left']='C←', ['c right']='C→', ['c ne']='C↗', ['c se']='C↘', ['c nw']='C↖', ['c sw']='C↙', } locallabel_aliases={ ['*']='asterisk', ['#']='hash', [':']='colon', [';']='semicolon', ['l-up']='l up', ['l-down']='l down', ['l-left']='l left', ['l-right']='l right', ['l-ne']='l ne', ['l-se']='l se', ['l-nw']='l nw', ['l-sw']='l sw', ['r-up']='r up', ['r-down']='r down', ['r-left']='r left', ['r-right']='r right', ['r-ne']='r ne', ['r-se']='r se', ['r-nw']='r nw', ['r-sw']='r sw', ['ps x']='ex', ['ps c']='circle', ['ps s']='square', ['ps t']='triangle', ['c-up']='c up', ['c-down']='c down', ['c-left']='c left', ['c-right']='c right', ['c-ne']='c ne', ['c-se']='c se', ['c-nw']='c nw', ['c-sw']='c sw', } localfunctionformat_key_press(args) localresult={} localchain=args.chainor' + ' fori,idinipairs(args)do locallc=id:lower() localtext=key_labels[lc]orkey_labels[label_aliases[lc]]orid locallabel=mw.html.create("kbd") :addClass("keyboard-key nowrap") :wikitext(text) table.insert(result,tostring(label)) end returnmw.getCurrentFrame():extensionTag{ name='templatestyles', args={src='Template:Key press/styles.css'} }..table.concat(result,chain) end functionp.key_press(frame) returnformat_key_press(frame:getParent().args) end returnp
