Editing
Module:Key
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- This module implements {{key press}}. local kbdPrefix = '<kbd class="keyboard-key nowrap">' local kbdSuffix = '</kbd>' local keyText = { ['caps lock'] = 'βͺ Caps Lock', ['[[caps lock]]'] = 'βͺ [[Caps Lock]]', ['shift'] = 'β§ Shift', ['[[shift key|shift]]'] = 'β§ [[Shift key|Shift]]', ['enter'] = 'β΅ Enter', ['[[enter key|enter]]'] = 'β΅ [[Enter key|Enter]]', ['cmd'] = 'β Cmd', ['[[command key|cmd]]'] = 'β [[Command key|Cmd]]', ['command'] = 'β Command', ['[[command key|command]]'] = 'β [[Command key|Command]]', ['opt'] = 'β₯ Opt', ['[[option key|opt]]'] = 'β₯ [[Option key|Opt]]', ['option'] = 'β₯ Option', ['[[option key|option]]'] = 'β₯ [[Option key|Option]]', ['tab'] = 'Tab βΉ', ['[[tab key|tab]]'] = '[[Tab key|Tab]] βΉ', ['backspace'] = 'β Backspace', ['[[backspace]]'] = 'β [[Backspace]]', ['win'] = 'β Win', ['[[windows key|win]]'] = 'β [[Windows key|Win]]', ['menu'] = 'β£ Menu', ['[[menu key|menu]]'] = 'β£ [[Menu key|Menu]]', ['up'] = 'β', ['[[arrow keys|up]]'] = '[[Arrow keys|β]]', ['down'] = 'β', ['[[arrow keys|down]]'] = '[[Arrow keys|β]]', ['left'] = 'β', ['[[arrow keys|left]]'] = '[[Arrow keys|β]]', ['right'] = 'β', ['[[arrow keys|right]]'] = '[[Arrow keys|β]]', ['asterisk'] = '*', ['hash'] = '#', ['[[#]]'] = '[[Number sign|#]]', ['colon'] = ':', ['[[:]]'] = '[[Colon (punctuation)|:]]', ['pipe'] = '|', ['[[|]]'] = '[[Pipe symbol||]]', ['semicolon'] = ';', ['[[;]]'] = '[[Semi-colon|;]]', ['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. ['ex'] = 'Γ', ['circle'] = 'β', ['square'] = 'β‘', ['triangle'] = 'β³', -- Nintendo 64 and GameCube. ['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 keyAlias = { -- ['alternate name for key (alias)'] = 'name for key used in key table' ['[[cmd key|cmd]]'] = '[[command key|cmd]]', ['[[cmd key|command]]'] = '[[command key|command]]', ['[[opt key|opt]]'] = '[[option key|opt]]', ['[[option key]]'] = '[[option key|option]]', ['[[opt key|option]]'] = '[[option key|option]]', ['[[win key|win]]'] = '[[windows key|win]]', ['*'] = '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 Collection = {} Collection.__index = Collection do function Collection:add(item) if item ~= nil then self.n = self.n + 1 self[self.n] = item end end function Collection:join(sep) return table.concat(self, sep) end function Collection:sort(comp) table.sort(self, comp) end function Collection.new() return setmetatable({n = 0}, Collection) end end local function keyPress(args) local chainNames = { 'chain first', 'chain second', 'chain third', 'chain fourth', 'chain fifth', 'chain sixth', 'chain seventh', 'chain eighth', 'chain ninth', } local result = Collection.new() local chainDefault = args.chain or '+' for i, id in ipairs(args) do if i > 1 then result:add(args[chainNames[i - 1]] or chainDefault) end local lc = id:lower() local text = keyText[lc] or keyText[keyAlias[lc]] or id result:add(kbdPrefix .. text .. kbdSuffix) end return mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = 'Template:Key press/styles.css'} } .. result:join() end local function keypress(frame) -- Called by "{{key press|...}}". -- Using the template doubles the postβexpand include size. return keyPress(frame:getParent().args) end local function press(frame) -- Called by "{{#invoke:key|press|...}}". return keyPress(frame.args) end return { keypress = keypress, press = press, }
Summary:
Please note that all contributions to Mirrorplay: Fae are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
MPFae:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information