Module:Key/sandbox
| This is the module sandbox page for Module:Key (diff). |
| This Lua module is used in MediaWiki:Clearyourcache, and on approximately 4,400 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 /sandbox 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. |
| This module uses TemplateStyles: |
Implements {{key press}}
local p = {}
local key_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↙',
}
local label_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',
}
local function format_key_press(args)
local result = {}
local chain = args.chain or ' + '
for i, id in ipairs(args) do
local lc = id:lower()
local text = key_labels[lc] or key_labels[label_aliases[lc]] or id
local label = mw.html.create("kbd")
:addClass("keyboard-key nowrap")
:wikitext(text)
table.insert(result, tostring(label))
end
return mw.getCurrentFrame():extensionTag{
name = 'templatestyles',
args = { src = 'Template:Key press/styles.css'}
} .. table.concat(result, chain)
end
function p.key_press(frame)
return format_key_press(frame:getParent().args)
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.