Template talk:Key press

From Wikipedia, the free encyclopedia
Jump to: navigation, search

Picture of a key[edit]

Resolved: Suggestion would violate WP guidelines.

I personally think we should have an actual picture of a key.

Keypress.png{{{1}}}

Sidious1701(talkemailtodo) 21:16, 13 January 2008 (UTC)

See WP:MOS#Images as text. Chris Cunningham (not at work) - talk 11:38, 14 August 2008 (UTC)
Doesn't work anyway. This does not look as-intended on Firefox 4, Win 7, for example; the value is next to, not on top of, the image. — SMcCandlish Talk⇒ ʕ(Õلō Contribs. 15:40, 19 June 2011 (UTC)

This rocks[edit]

Man, I love this template. Thanks folks. Is it advertised anywhere in the VG projects? I'd never seen it until today. Chris Cunningham (not at work) - talk 10:39, 14 August 2008 (UTC)

By "VG projects" I assume you mean "Video Game projects"?
You got a point in that it needs to be advertised. But from what I see in "What links here" it wasn't advertised anywhere. So I have now added it to Wikipedia:Template messages/Format.
--David Göthberg (talk) 20:11, 23 March 2009 (UTC)

Concur with Chris' comment - this template is lovely. — Hex (❝?!❞) 21:51, 25 February 2012 (UTC)


Using :before CSS class to show images[edit]

This would probably be better accessibility-wise than having users manually include symbols. It's supported by mosy standards-compliant browsers. Chris Cunningham (not at work) - talk 10:42, 14 August 2008 (UTC)

Bah. I've realised that this won't work, because pseudo-classes can't be styled using style attributes. I suppose something could be added to common.css, but that's a bit more work than I'd have liked. Chris Cunningham (not at work) - talk 11:36, 14 August 2008 (UTC)

Nowrap is creating a problem[edit]

It might just be my browser, but when I resize the text in Table of keyboard shortcuts, some of the keys overflow the table cells. --Nezek (talk) 08:53, 1 March 2009 (UTC)

I'd just add spaces before and after the "+", to create a break opportunity between the keys. —Ms2ger (talk) 10:21, 1 March 2009 (UTC)
I have added Ms2ger's explanation to the "Technical details" section of the documentation of this template.
--David Göthberg (talk) 17:53, 23 March 2009 (UTC)

.keyboard-key[edit]

I have left a message over at MediaWiki talk:Common.css#.keyboard-key, regarding the .keyboard-key CSS class in this template.

--David Göthberg (talk) 04:52, 23 March 2009 (UTC)

That discussion resulted in that we removed the .keyboard-key class from MediaWiki:Common.css. But we still have the class name in the template itself, so users can still style the keyboard keys by adding code in their /monobook.css and using the !important keyword to override the styles.
--David Göthberg (talk) 01:08, 24 March 2009 (UTC)

My rework of this template[edit]

I have just reworked the code of this template. There's no change in looks and no real change in functionality. Here's what I have done and why:

1: I moved the code that was used repeatedly to the {{keypress/core}} sub-template. I also moved the unicode symbol inserting code from the old subtemplate {{keypress/Switch}} to /core. This means {{keypress/Switch}} is not used anymore. But I think we should keep the old /Switch template for reference and otherwise {{keypress}} looks seriously broken when looking at older versions of it. Since we already had the /Switch sub-template which was always called this means no change in efficiency. (Note that it takes some time before the "What links here" lists are updated, since pages are only re-rendered when visited.)

2: I added a "←" symbol when "Backspace" is fed, thus rendering "← Backspace".

3: I simplified/compacted the CSS style code somewhat. (See the code in {{keypress/core}}.) It causes no change in appearance. And these keys look fine in the browsers I have (a very old IE 5.5, a slightly old Opera 9.02 and a Firefox 2.0).

4: This template used to be able to take 10 key parameters. But the worst case I could find only used 4 parameters, so 10 seems to be overkill. I lowered it to 5 to still have some margin. To make sure I made it so this template reports into Category:Wikipedia keypress template parameter needs fixing if it gets too many parameters. This means we can easily find those pages and fix them, or we can discover if we need to make this template take more parameters. It usually takes about 2 weeks until nearly all cases get visible in such a category, since pages are only re-rendered when someone visits them. I made the category hidden for now, so we can have a look at the cases (if any) without most other editors noticing. So we can decide on how many parameters we need. After about 2 weeks when we have had our look we should make the category visible, so editors that use this template on pages will notice when they use too many parameters.

--David Göthberg (talk) 18:25, 23 March 2009 (UTC)

Colon, Pipe, Star - special characters[edit]

It does not seem to work for a colon or pipe:

  • {{Keypress|:}} produces ;
  • {{Keypress||}} produces (perhaps this is not unexpected - but what is the workaround?)
  • {{Keypress|*}} produces *

and just to prove (to myself) that I have the correct syntax:

  • {{Keypress|1}} produces 1

Anyone know how to fix this? --Robinson weijman (talk) 12:56, 5 May 2010 (UTC)

*, :, ;, and | are wikimarkup, so these are problematic. However {{Keypress|{{!}}}} | works (as does {{Keypress|{{;}}}} ;).
I've adapted the sandbox (and now the template). You can now use them in the following way:
Asterisk: {{keypress|*}} * Linked: {{keypress|[[*]]}} *
Colon: {{keypress|:}} : Linked: {{keypress|[[:]]}} :
Semicolon: {{keypress|{{;}}}} ; Linked: {{keypress|[[;]]}} ;
Pipe: {{keypress|{{!}}}} | Linked: {{keypress|[[|]]}} |
EdokterTalk 19:21, 2 September 2010 (UTC)
Equals sign also needs to be treated separately:
{{Keypress|{{=}}}} =
I've added a replacement for the number sign:
{{keypress|#}} #
{{keypress|[[#]]}} #
Simo Kaupinmäki (talk) 23:37, 6 September 2010 (UTC)
Thanks for updating the template and the doc. However, bolding the small diacritics has no effect, as the font is too small, so I have removed those. Best is to keep /core as small as possible. EdokterTalk 03:03, 7 September 2010 (UTC)
Thanks for the fixes, Edokter! --Robinson weijman (talk) 12:00, 7 September 2010 (UTC)
Well, the effects of bolding the small diacritics (´`¨) depend on the font settings of your browser and the resolution of your screen. Compared with unbolded characters (´`¨) I can see a difference particularly in the diaeresis. However, generally I suppose you are right, so it may not be worth putting extra code in the core. Thanks for pointing that out. — Simo Kaupinmäki (talk) 13:29, 7 September 2010 (UTC)
OK, this left me wondering: what are the exact downsides of a bigger core? Is it just that generally it's a good idea to keep things simple, or may additional code cause more concrete problems? I ask this because my understanding of creating templates is still limited. I've just copied this template into fi.wikipedia with some modifications and additions, and while some of the additions (such as the bolded diaeresis) may be useful in a specific user case, they are not essential. It would be interesting to learn more about the principles of optimizing the code. — Simo Kaupinmäki (talk) 17:44, 7 September 2010 (UTC)

Page Up/Page Down[edit]

These keys do not have symbols; they never had. I intend to remove them from /core. Any objections? EdokterTalk 18:08, 2 September 2010 (UTC)

I have removed them. EdokterTalk 00:13, 3 September 2010 (UTC)
Older Apple keyboard, German layout
You have never used an (older) Apple keyboard nor read an ISO standard, I assume. ⇞ Page Up and ⇟ Page Down (cf. ⎗ Prev. Page and ⎘ Next Page), also ⇱ Home and ⇲ End as well as ⌧ Clear, ⌅ Enter, ⌦ Del, ⇪ Shift Lock, ⌥ Alt, Tab ⇥, ↵ Return and ⌘ , but not ⌫ Erase, ⎋ Esc or ⌃ Ctrl. — Christoph Päper 09:35, 16 July 2015 (UTC)

Opera allows a line break after the left border of a key image[edit]

Unfortunately it seems that Opera allows a line break after the left border (!) of the first key image produced by a template, thus breaking the image. You can prevent this from happening by disallowing a break right before the template by using a no-break space between the template and the preceding character. In the case of several adjacent templates you can wrap them all together with <span style="white-space: nowrap;">.

Is there any better way to prevent these brain-dead line breaks? —Preceding unsigned comment added by Simo Kaupinmäki (talkcontribs) 18:52, 7 September 2010 (UTC)

Unfortunately, no. The core template is already wrapped in a no-wrap span. Wrapping it in another span is ugly, and may not solve the problem. But I will try to eliminate preciding spaces. EdokterTalk 01:42, 8 September 2010 (UTC)
Thanks for the effort, but it doesn't seem to help. And you were correct in assuming that putting the no-wrap span into the main template does not make any difference either. I even tried to replace the regular spaces in the main template with no-break spaces, but to no avail. It looks like the odd line breaks can't be prevented from within the template, so if you want to play safe, you need to separately disallow breaking just before each template. Too bad. – Simo Kaupinmäki (talk) 12:43, 8 September 2010 (UTC)

Mouse buttons[edit]

Can I make a request to include mouse buttons e.g.:

  • left mouse button (or just LMB)
  • middle (MMB)
  • right (RMB)
  • wheel up (MWU)
  • wheel down (MWD)

Something like that? --Robinson weijman (talk) 09:30, 5 October 2010 (UTC)

You can already put in anything you want; you just have to enter exactly what you want to show, like LMB, but this template wasn't intended with mouse buttons in mind. EdokterTalk 14:04, 5 October 2010 (UTC)
Ah, yes, of course. Thanks! --Robinson weijman (talk) 06:16, 6 October 2010 (UTC)
You could also use LMB click.svg RMB click.svg Mouse wheel up.svg Mouse wheel down.svg. ›mysid () 13:15, 6 October 2010 (UTC)
Nice one - can anyone (with expertise) add them to the template? I might be tempted to give it a go... =:-) —Preceding unsigned comment added by Robinson weijman (talkcontribs) 18:36, 9 October 2010 (UTC)
You can expiriment in the sandbox, but I do believe mouse buttons are outside the scope of this template. {{Mouse click}} perhaps? EdokterTalk 19:00, 9 October 2010 (UTC)
Another thing to consider is that the functions of the left and right mouse button are often reversed for left-handed people, in which case such images can be rather confusing. (Therefore it is also better to speak of primary and secondary mouse buttons unless you know for sure that the user's mouse has been configured to function as right-handed.) – Simo Kaupinmäki (talk) 23:01, 10 October 2010 (UTC)
Furthermore, this would generally violate the guidelines at WP:ICONS - don't use iconic images as cutesy replacements for simple wording unless there's a very good reason to do so (e.g. because in a wide and long table of sporting statistics,  IRL is more concise than Republic of Ireland, and flags actually usually help people find the competitors they are interested in, thus their use in Olympics Games broadcasts, etc.). And yes, it would need to be a different mouse click template even if it wasn't an obvious WP:ICONS problem, since they would serve different purposes. — SMcCandlish Talk⇒ ʕ(Õلō Contribs. 09:25, 19 June 2011 (UTC)

Caps Lock symbol[edit]

What I've seen on some keyboards and in the keyboard template is that the Caps Lock key has a solid version of the upward pointing arrow that is used for the shift key. Is there a unicode solid arrow that can/should be used?Naraht (talk) 14:10, 14 February 2011 (UTC)

Arrow (symbol). — Dispenser 15:16, 14 February 2011 (UTC)
Upwards Thick Arrow From Bar 0x21ea may be appropriate.Naraht (talk) 16:41, 14 February 2011 (UTC)
I've added it. Edokter (talk) — 16:59, 14 February 2011 (UTC)
ISO/IEC 9995: ⇧ Shift vs. ⇪ Shift Lock vs. ⇬ Caps Lock (and ⇧ Level 2 vs. ⇮ Level 3 vs. ⇯ Level 3 Lock or ⇨ Group vs. ⇰ Group Lock) — Christoph Päper 09:21, 16 July 2015 (UTC)

The element kbd[edit]

Resolved: Fixed.

Shouldn't this be <kbd class="keyboard-key"...> instead of <span class="keyboard-key"...>? It took several years to get the MediaWiki developers to properly and fully support the semantic markup elements like <kbd>, <dfn>, etc. Shame not to actually use them for their intended use. Especially since <span> has no semantic meaning at all, much less an appropriate one. — SMcCandlish Talk⇒ ʕ(Õلō Contribs. 09:20, 19 June 2011 (UTC)
PS: After this is fixed, the template should be added to Category:Semantic markup templates and its Template:Kbd shortcut added to Category:Wikipedia XHTML tag-replacing templates. — SMcCandlish Talk⇒ ʕ(Õلō Contribs. 09:33, 19 June 2011 (UTC)

<kbd> turns the text into a monospace font, which is not what we want. So while maybe semantically correct, visually it looks horrible. Edokter (talk) — 13:14, 19 June 2011 (UTC)
Forgot about that. It's an easy CSS fix: Template:Key press/Sandbox. Barring any objections, I'd like to install this. — SMcCandlish Talk⇒ ʕ(Õلō Contribs. 15:43, 19 June 2011 (UTC)
Yes check.svg Done. Edokter (talk) — 16:29, 19 June 2011 (UTC)
I added the semantic markup category, and also made {{kbd}} a new, more general-use template in the XHTML tag replacements category (as a redirect to this template, the name was only used in one place). — SMcCandlish Talk⇒ ʕ(Õلō Contribs. 21:11, 19 June 2011 (UTC)

Thorn (letter) and other Alt Gr uses[edit]

Thorn (letter) is showing up at Category:Wikipedia keypress template parameter needs fixing. The thing is, I think its use of more than 5 keystrokes is legitimate: it's a composition using Alt Gr, which has to be held down for the duration of the sequence. Anyone know what the upper bound on these sequences is? If it's six characters, for instance, we can just slightly expand this codebase, whereas if it's open-ended we might want to rethink having a cleanup category for these. Chris Cunningham (user:thumperward) (talk) 15:52, 11 May 2012 (UTC)

This template has a limit of five parameters indicating consecutively pressed keys (indicated with a '+' between the keys). Any keys types in sequense must be entered using a new instance of the template. Edokter (talk) — 19:47, 11 May 2012 (UTC)
Right, but the problem is how to represent a sequence which is "hold the Alt Gr key while typing these five characters in sequence, then release the Alt Gr key". Is it possibly worth concocting some sub-template at {{Alt Gr}} to handle this use case? Chris Cunningham (user:thumperward) (talk) 09:13, 12 May 2012 (UTC)
How about alt+(012828) ? Edokter (talk) — 20:52, 12 May 2012 (UTC)
I concur with Edokter; that's a simple solution that doesn't require any new templates or more complicated template code. — SMcCandlish   Talk⇒ ɖ∘¿¤þ   Contrib. 07:41, 13 May 2012 (UTC)
Sounds good. That would empty the cleanup category. To be quite honest, I'd rather simply have it error out than silently do the wrong thing and categorise pages for cleanup: any objections to making that change? Chris Cunningham (user:thumperward) (talk) 09:38, 13 May 2012 (UTC)
If you read through the template documentation, you can see that the solution mentioned by Edokter has also been suggested there – though without the parentheses. I don't think parentheses are really necessary here, as lack of punctuation between digits makes them appear as a group. – Simo Kaupinmäki (talk) 17:45, 27 June 2012 (UTC)
Sorry for necromancing this discussion, but {{key press|alt}}+({{key press|0|1|2|8|chain=}} does the same but is shorter. I don't know when the chain parameter was added so it might not be available 1.5 years ago. — xZise [disc] 19:08, 9 December 2013 (UTC)

DS/Wii and Electronic arrow button key[edit]

There was some discussion at Wikipedia:Templates for discussion/Log/2013 May 29#Template:DS/Wii key press with the outcome that this could be potentially merged here. The code is now in User:QM400032/DS/Wii key press and User:QM400032/Electronic arrow button key press. If this is needed or wanted, you may want to consider merging them. However, the author is currently indef blocked. Thanks! Plastikspork ―Œ(talk) 14:07, 7 June 2013 (UTC)

Should there a distinction between left/right shift keys added?[edit]

I used this template (and the core template) for the Kerbal Space Programm Wiki. There I required a right shift so I added there right and left shift/2nd level, with the same features as the usual shift. Should this change added back into here? — xZise [disc] 11:56, 8 December 2013 (UTC)

Pollution[edit]

Over the last months, this template has been terribly polluted with all sorts of symbols that do not normally appear on a computer keyboard. This makes the template, and the pages it is used on, appear very messy (especially the shift/ctrl/alt sympbols). I am once again going to remove all sympbols that do not appear on a normal computer keyboard, for which this tempate was originally designed. Edokter (talk) — 12:39, 8 December 2013 (UTC)

@Edokter: Have you reviewed the recent changes? It looks like some well-intentioned people have added such symbols in again.
Maybe it would be best to leave some comments about these keys being deliberately omitted, and perhaps a nice big comment right at the top of {{key press/core}} stating that "This template should NOT show symbols that ARE NOT found on the keys". Unfortunately, I see that my keyboard has arrows on the shift keys.
And, you know, consider protecting the template more fully.
If you don't want to protect it, you might want to avoid removing the multimedia keys and such that would always bear those symbols on any keyboard that has them, along with the " key" variants that display strange symbols without words; removing them seems likely to lead to (very slow, perhaps unintentional) revert wars. —SamB (talk) 03:19, 18 February 2014 (UTC)

Most of the removed symbols come from ISO/IEC 9995-7. Most of them are or have been present on actual physical keyboards. — Christoph Päper 18:50, 21 October 2014 (UTC)

For those who need less frequent key symbols, there now is {{key top}}. — Christoph Päper 09:12, 16 July 2015 (UTC)

Separator for Key Sequences[edit]

This template's doc does not describe which separator to use in case some keys are pressed in sequence, for instance in Alt+Space N to minimize (iconify) a window. I used a space here but this is not handled consistently in WP: someone else could have used Alt+Space, N, Alt+Space-N or Alt+SpaceN. -- Juergen 37.252.110.97 (talk) 21:46, 8 June 2014 (UTC)

Key press change, or maybe new template "escape series"?[edit]

ANSI and VT codes consist of strings of characters, generally proceeded by the escape. To display these, someone suggesting using this template. It looks good, but it is hard to enter, because the template normally inserts plusses if multiple characters are entered in a single string. I don't want "press escape at the same time as I and 0", I need "press escape THEN I and THEN 0. Perhaps a flag to suppress the plus signs? Or maybe a different version that does it by default? Maury Markowitz (talk) 15:30, 5 February 2015 (UTC)

You can simply use the template multiple times: Esc I O. 18:28, 5 February 2015 (UTC)
Sure, but it's hard. Lots and lots of typing that's hard. Maury Markowitz (talk) 19:15, 5 February 2015 (UTC)
It turns out you can remove the "+" with |chain= (leave it empty). -- [[User:Edokter]] {{talk}} 19:38, 5 February 2015 (UTC)
  • I've started {{ESC}} for this purpose. I'll neaten it up and finish it in the next few hours. In class waiting for the instructor to show up at the moment. — {{U|Technical 13}} (etc) 20:13, 5 February 2015 (UTC)

Thanks to both Edokter and Tech, I'll make widespread use of both! Maury Markowitz (talk) 12:16, 6 February 2015 (UTC)

missing section in the description[edit]

In the current version of Template:Key_press/doc [1] the first para in the Key symbols section refers to some 'Arrows exception below' — but there's no 'arrows exception' below... --CiaPan (talk) 08:49, 9 July 2015 (UTC)

Removed. Documentation pages are usually not protected, so you can fix them yourself. -- [[User:Edokter]] {{talk}} 20:38, 9 July 2015 (UTC)
@Edokter: Thank you. I know I could fix it myself—if I only knew how. So far I didn't know if that was a wrong reference (in 'arrows exception' semi-title OR in the direction indicator 'below') or possibly the 'arrows exception' has been deleted some time ago (and whether it should be restored or the reference removed accordingly) or may be the 'arrows exeption' part was intended to be added but somehow somebody missed it, so it is still absent. That's why I posted my observation here, in hope someone more fluent in English AND in the template history and use will do the work better than me. --CiaPan (talk) 07:32, 13 July 2015 (UTC)
Ah OK. It was probably a reference to a deleted section. At one time, the template supported a multitude of arrows, but which were ususally not found on keyboards, so they were removed. -- [[User:Edokter]] {{talk}} 17:11, 13 July 2015 (UTC)