244

<kbd> is a great way to mark up text to be entered. But when you use it on Stack Exchange sites, it's really difficult to read. For instance, say I typed this sentence by starting with a Shift+F, then used o, followed by r, then space, you can see that it quickly becomes an unreadable mess of boxes and smashed-together type.

Whoever is in Ctrl of the visual design should probably fix it.

Also, I'm so very sorry. Please don't let the silly answers below discourage you from fixing the styling.

12
  • 1
    That's why you use them judiciously (goofy, but awesome!, answers below withstanding) and use the necessary white space to make the post look good. I think it's pretty cool.
    – raven
    Commented Jul 2, 2009 at 20:21
  • 294
    Now all they need is an onclick handler to make them look like you are pressing them. Then an alert box pops up and says "On your keyboard, idiot!".
    – Macha
    Commented Jul 2, 2009 at 20:25
  • 33
    ok improved, will deploy later Commented Jul 5, 2009 at 7:14
  • 2
    Thanks for taking care of the little things like that Jeff. The polish really does help make this a great site.
    – jjnguy
    Commented Jul 7, 2009 at 20:36
  • 72
    @Macha jQuery('kbd').click(function(){alert('On your keyboard, idiot!');});
    – Yahel
    Commented Jan 8, 2011 at 18:31
  • 1
    @Mache: see my answer :P
    – user153011
    Commented Jan 14, 2011 at 13:07
  • +1, but for the current rendering too! Still too ugly, and hardly ever useful in my opinion.
    – Arjan
    Commented Nov 28, 2011 at 18:12
  • 8
    The kbd graphics are cool in my opinion why get rid of them? Commented Apr 15, 2013 at 15:28
  • 1
    why doesn't this work on Mathematics?
    – Ephraim
    Commented Jun 23, 2014 at 4:44
  • Protected this to prevent at least some of the abusers to abuse the <kbd> tags. Commented Sep 1, 2016 at 22:04
  • 1
    @Ephraim it appears to work just fine now, at least in preview Commented Sep 1, 2016 at 22:11
  • 2
    Got a new MacBook Pro with Touch Bar, just came here for ESC
    – Alex Wiese
    Commented Mar 8, 2017 at 0:44

20 Answers 20

111
kbd {
    -moz-background-clip: border;
    -moz-background-inline-policy: continuous;
    -moz-background-origin: padding;
    background: #EEEEEE none repeat scroll 0 0;
    border-color: #CCCCCC #AAAAAA #888888 #BBBBBB;
    border-style: solid;
    border-width: 1px 1px 2px 2px;
    color: #000000;
    padding: 2px 1px;
    white-space: nowrap;
}

...would make <kbd> a bit less broken:

Demonstration of above CSS

Sadly, it breaks Pesto's castle.

4
  • +1: Seems to be the default padding in the SO CSS that is the problem. BUt changing it would probably destroy most of the answers here :-)
    – Richard
    Commented Jul 3, 2009 at 10:23
  • Is this something one can run using Tampermonkey as a script to override the default <kbd>...</kbd> specification? If so, how do you go about doing that?
    – Werner
    Commented Jul 14, 2014 at 20:39
  • @Werner It would be very easy to do with the "Stylish" addon for Chrome/Firefox. Also definitely doable with Tampermonkey, you'd just need to inject the CSS via Javascript (searching for "tampermonkey add css" should find something).. but in this specific case, why do you need to? The site has been updated to make the kdb element much nicer
    – dbr
    Commented Jul 15, 2014 at 13:51
  • 1
    @dbr: Not on TeX - LaTeX where I contribute mostly.
    – Werner
    Commented Jul 15, 2014 at 15:30
802

                                                                                                               
                                                                                           
                                                                                           
                                                                                            
                                                                                            
                                                                                            
                                                                                                                               
                                                                                                  
                                                                                                        
                                                                                                  
                                                                                                          
                                                                                                      
                                                                                                              
                                                                                                  
                                                                                                              
                                                                                                  
                                                                                                              

OUR PRINCESS IS IN ANOTHER CASTLE!


original keyboard castle

27
  • 378
    You've just beaten the internet.
    – Eric
    Commented Jul 2, 2009 at 21:03
  • 8
    I just had a flashback to elementary school and NES-filled nights.. so awesome! Commented Jul 5, 2009 at 7:02
  • 5
    It probably looks different on every combination of screen size, resolution, font, and operating system. On mine the blank spaces are too small. Commented Jul 5, 2009 at 15:51
  • 81
    Slow work day, wasn't it?
    – perbert
    Commented Jul 28, 2009 at 17:01
  • 5
    Did you use a script for this? Or all by hand...
    – Zifre
    Commented Jul 28, 2009 at 18:42
  • 87
    A true artiste does it all by hand, though there may have been some cut-and-paste. Commented Jul 28, 2009 at 18:50
  • 47
    Despite being empty of princess, this castle is full of win.
    – matpie
    Commented Aug 5, 2009 at 22:49
  • 37
    Oh noes! Now the castle is in another castle!
    – random
    Commented Sep 26, 2009 at 5:49
  • 2
    I rolled it back now that the <kbd> element is back! Commented Nov 22, 2010 at 1:45
  • @George, but it looks different?
    – Arjan
    Commented Nov 27, 2010 at 22:54
  • @Arjan: Not my fault :P Commented Nov 27, 2010 at 22:59
  • But you did break the nice result, @George!
    – Arjan
    Commented Nov 27, 2010 at 23:04
  • @Arjan: I just rolled it back to the way it was originally! Commented Nov 27, 2010 at 23:06
  • 22
    Uh oh. I think the castle is now slightly lopsided. Unexpected geological activity!
    – nhinkle
    Commented May 5, 2012 at 1:16
  • 1
    I needed 15+ years to realize that all those castles look indeed like skulls.
    – Sliq
    Commented May 16, 2013 at 23:09
370


 Esc      F1F2F3F4   F5F6F7F8   F9F10F11F12   PrtScScrLkPse

 `  1  2  3  4  5  6  7  8  9  0  -  =   ←  Bksp       Ins HomePgUp
  Tab  ↹    Q  W  E  R  T  Y  U  I  O  P  [  ]  \     Del  End  PgDn
  Caps   A  S  D  F  G  H  J  K  L  ;  '   ↵  Enter    
  ⇧  Shift       Z  X  C  V  B  N  M  ,  .  /    ⇧  Shift                           ↑   
  Ctrl    ⊞    Alt                                                               Alt    ⊞    Ctrl        ←     ↓     →  

I'll put the NumPad below, 'cause it wouldn't fit if I placed it beside the keyboard.


Num /  *  - 
 7  8  9  +  
 4  5  6  + 
 1  2  3 En
      0       .  ter

This is the most fun I've had all day.


original keyboard

10
  • 18
    +1 for the completion of what I tried to do...but also +1 because trying was also the most fun I've had...although... Commented Jul 2, 2009 at 19:46
  • 3
    Try and change it to the Billy Mays button
    – TheTXI
    Commented Jul 2, 2009 at 19:53
  • 11
    Hey, where's the spacebar?
    – fretje
    Commented Jul 2, 2009 at 20:25
  • 273
    Whoneedsaspacebar?
    – mmyers
    Commented Jul 2, 2009 at 20:27
  • 26
    Now try a UK keyboard with a double height enter key :-)
    – Richard
    Commented Jul 3, 2009 at 10:21
  • 1
    are the m, j, l, and i letters on that keyboard (in jeff's link) a little bit red or am I going insane? Maybe I'm a synesthete. Commented Aug 5, 2009 at 22:37
  • 1
    @Carson Either you're not insane or I am too.
    – deleted
    Commented Aug 20, 2009 at 23:27
  • 5
    I can see the red, it might be a result of anti-aliasing, think of the subpixels!
    – Liam
    Commented Sep 8, 2010 at 15:48
  • 1
    Updated keyboard to new format :D (with a spacebar, @mmyers :P)
    – Riking
    Commented Mar 11, 2013 at 23:26
  • 1
    I made many changes to the keyboard. I fixed the spacing, so the keyboard looks more rectangular in shape. I also changed it into a Windows keyboard. I added function keys. I replaced arrow keys. I added 9 keys above the arrow keys. I added the NumPad. And lastly, I added the keyboard background and borders. Commented May 3, 2018 at 7:52
161

This is a very old post and the system has changed, it includes the original code for the keyboard and below it the image it generated, currently the original code does not make a good keyboard.


Trying out beat Pesto's keyboard. Mine has square buttons and correct spacing between items.

 °  1  2  3  4  5  6  7  8  9  0  ö  - Backspace  
Tab     q  w  e  r  t  y  u  i  o  p  ð  ' ENTER    
Caps       a  s  d  f  g  h  j  k  l  æ  ´  +            
Shift   <  z  x  c  v  b  n  m  ,  .  þ Shift                 
Ctrl        ❖   Alt                    Space                   Alt    ❖   Menu Ctrl 


Original (image form)

alt text

13
  • 15
    The right Ctrl key is sticking out to the right for me (on IE7). Is it meant to be flush with the others?
    – mmyers
    Commented Jul 2, 2009 at 20:29
  • 6
    Here as well (FF3)
    – fretje
    Commented Jul 2, 2009 at 20:30
  • Cant test IE7 :S He is a little bit to the right here but only 1 pixel or so (FF 3.5) Commented Jul 2, 2009 at 20:31
  • The right edge of the Shift key is about even with the 'r' in "Ctrl".
    – mmyers
    Commented Jul 2, 2009 at 20:33
  • I think it's more that the 4th line is sort. Commented Jul 2, 2009 at 20:33
  • Ok wow, well im on linux so the font difference is a possible culprit. Commented Jul 2, 2009 at 20:33
  • 6
    There's quite a difference on Chrome. The third line is about 1 pixel longer (but that's only noticeable 'cos I'm looking). Oh, don't think I'm not impressed BTW.
    – ChrisF Mod
    Commented Jul 2, 2009 at 20:37
  • Ok i see the issue in IE now. Ill propose a patch for it soon and commit it to jeff so my keyboard always looks good :D Commented Jul 2, 2009 at 20:39
  • @Jeff is this after the change on a Windows machine? Since on Linux this keyboard has about a 10 pixel space between each line. Or is that the intended change? Commented Jul 5, 2009 at 12:04
  • Opera v9.64: the right Ctrl key is sticking out to the right. Commented Aug 5, 2009 at 23:30
  • @Peter it no longer looks as intended. Check out Jeffs image here in the comments. Commented Aug 6, 2009 at 10:40
  • +1 - Thanks for providing those who hadn't seen the old -vs- new, the opportunity to do so. This should be pinned at the top of the answers! :)
    – user66001
    Commented Sep 10, 2013 at 18:03
  • The design of <kbd> element has probably changed more than 2 times already, but I like the current keyboard more. It's not bad, just more modern.
    – EvgenKo423
    Commented Jul 28, 2019 at 9:53
160

I tried to make a keyboard and failed miserably. :(

Although I will present this:

Any

The mystical Any key.

0
157

Shiftt h i s space i s space w h y space w e space c a n ' t space h a v e space n i c e space t h i n g s .

Or so I'm told.

6
  • 24
    I thought we couldn't have nice things because of me. But I guess it was you all along. Commented Jul 2, 2009 at 19:25
  • 12
    Shouldn't the T be a Shift+t?
    – user138231
    Commented Jul 1, 2012 at 19:48
  • 16
    @Chichiray FREE COUNTRY I DO WHAT I WANT Commented Jul 5, 2012 at 21:48
  • 17
    IN UR POST USIN MY FREEDOMS
    – badp
    Commented Oct 25, 2012 at 21:02
  • 8
    @badp: Because that really needed to be fixed.
    – user102937
    Commented Oct 25, 2012 at 21:06
  • Shift + t makes T (as opposed to t^Ht^Httt^H^H^H Shift Shift Shift Shift Shift Alt y T).
    – wizzwizz4
    Commented Oct 28, 2017 at 18:57
127

Esc     F1F2F3F4   F5F6F7F8   F9F10F11F12  PrSnScLkBrek

 `  1  2  3  4  5  6  7  8  9  0  -  = Backspace  Ins HomePgUp  
Tab   q  w  e  r  t  y  u   i   o  p   [    ]    \          Del  End PgDn
Caps    a  s  d  f  g  h   j   k   l   ;   '    Enter         
Shift         z  x  c  v  b  n  m   ,    .   / Shift                             ▲  
Ctrl   Win Alt                                                        Alt   Win MenuCtrl    ◀   ▼    ▶  

I couldn't find my keyboard layout here, so I thought I'd post it. You guys are using real small keyboards... (image below for posterity in case the CSS changes in future)

rendered 20-11-2012

4
  • Best one yet. I am in awe. Commented Nov 20, 2012 at 4:15
  • 49
    I'm horrified at the amount of time you must have spent on building this! ;) Commented Nov 20, 2012 at 7:29
  • Finally, a propper M+104 keyboard layout... though I prefer my Unicomp 103-key, which has original spacing.
    – Tracker1
    Commented Aug 13, 2015 at 1:21
  • Brek sounds pretty funny to me. I was going to suggest Brk, but that sounds more like bark now.
    – byxor
    Commented May 1, 2017 at 11:06
126

Felt sorry for the poor broken{*} castle, felt that it MUST be fixed as a tribute to the history of meta.

Take THAT, Jin!!

*Today I realised that non-breaking spaces can break stuff as well O-0

                                                                                   
                                                                    





                               
                                                                                  

                                                                            

                                                                                  

                                                                                  

                                                                                  

                                                                                                                            

                                                                                   

                                                                                         

                                                                                    

                                                                                           

                                                                                                 

                                                                                                       

                                                                                             

                                                                                                       

                                                                                            

                                                                                                        

OUR PRINCESS IS IN ANOTHER CASTLE!

6
  • 3
    Our princess could never be in that castle. It's so... plain ... and white.
    – Cody Gray
    Commented May 7, 2012 at 10:34
  • @ThE blame Jin, not me. ;-) Commented May 7, 2012 at 10:46
  • 28
    I bow to your brick laying skills.
    – Jin Mod
    Commented May 8, 2012 at 5:07
  • @Jin: Technically, they're tiles, now that someone changed the design ;-) . Anyway, the design is actually much better--I just felt sorry for the poor castle :P Commented May 8, 2012 at 5:19
  • 8
    @animuson The flag has a unicorn! Try doing THAT with inline code blocks! Commented May 9, 2012 at 7:55
  • png files can have clear transparent pixels and pixels in a jpeg. imgur.com always converts .png to .jpeg where every 100% transparent pixel becomes 100% jet black. I have no idea how you got the horse on a bed of grass to show up with a clear transparent background instead of a black one. Commented Sep 22, 2022 at 22:57
109

I totally agreeI totally agreeI totally agreeI totally agreeI totally agree

I totally agree

this is another pyramid lol.

You know, I totally agree.
You see, on my posts I'm never intrusive, that's why I never use <kbd></kbd>

Though I always wanted to make an unpressable button.

And, ladies and gentlemen, the nothing-button!

You see, now that this is fixed,

I use buttons all day long.

3
  • 23
    Wow it's even worse than backticks... hope it won't become the new formatting trend any time soon! Commented Feb 9, 2014 at 21:48
  • 5
    Lol, I'm going to start putting all my answers in a Button Nexus like above to draw more attention to them.
    – xdhmoore
    Commented Dec 19, 2015 at 20:33
  • 9
    The top two look like a Scratch program when you try to do anything clever!
    – hat
    Commented Dec 29, 2017 at 7:47
75

You don't need keyboards to make castles! Inline code blocks work just as well!

Look, it has a flag! Try doing that with keyboards!

                                                 
                                                 
                                                 
                                         
                                         
                                         

                                                               

                                           

                                               

                                                         

                                                     

                                                         

                                                                    

                                                

                                            

                                                

                                            

                                                       

                                                      

                                                             

                                                     

                                                             

                                                     

                                                             

P.S. The new keyboard styles are awesomesauce. The unicorns are happy.

3
  • 16
    cough Commented May 9, 2012 at 18:39
  • 2
    @Ullallulloo: Yes, I know, he completed my challenge. Then I threatened to pull out the ASCII art, which I may yet still do.
    – animuson StaffMod
    Commented May 9, 2012 at 19:05
  • 1
    @animuson I'm still waiting.
    – ItamarG3
    Commented May 24, 2018 at 14:09
71

I would like to propose that from here on out we replace

Caps Lock

with

Billy Mays

William Darrell "Billy" Mays, Jr. (July 20, 1958 – June 28, 2009) was an American television direct-response advertisement salesperson most notable for promoting OxiClean, Orange Glo, and other cleaning, home-based, and maintenance products. His distinctive beard and loud sales pitches made him a recognized television presence in the United States.

4
  • 11
    Seconded. Now only to get PC makers to get on this. Commented Jul 2, 2009 at 19:37
  • 27
    MAY HE REST IN PEACE!!!
    – Bill the Lizard Mod
    Commented Jul 2, 2009 at 20:08
  • 6
    Was he similar to BRIAN BLESSED?
    – TRiG
    Commented Aug 6, 2011 at 1:29
  • RELATED!
    – 3D1T0R
    Commented Jun 22, 2018 at 3:12
70

Atwood should have never told us about this. This will only end in disaster.

53

BA

2
  • 7
    +1 for an actual legitimate usage of <kbd> (plausibly on gaming.SE). Commented Jun 30, 2016 at 3:18
  • 12
    Where's start?
    – byxor
    Commented May 1, 2017 at 11:09
45

I couldn't resist:-)

Which computer had this keyboard?

    ⟵ 1  2  3  4  5  6  7  8  9  0  +  -  £ HOMEDEL      f 1 

   CTRL Q  W  E  R  T  Y  U  I  O  P  @  *  ↑ RESTORE      f 3 

RUNSHIFT A  S  D  F  G  H  J  K  L  :  ;  = RETURN         f 5 

C=SHIFT Z  X  C  V  B  N  M  ,  .  / SHIFTCRSRCRSR         f 7 

                                                           

7
  • 3
    I give up. Which is it? Commented Aug 5, 2009 at 22:44
  • 8
    en.wikipedia.org/wiki/File:Commodore64.jpg
    – John Fouhy
    Commented Aug 5, 2009 at 23:00
  • 7
    The function keys give that away, if only from a top view. Its also the C-64C.
    – user50049
    Commented Jul 1, 2010 at 23:22
  • 5
    @Tim: there's also a [restore] key; I've never seen that on another system. Commented Dec 3, 2010 at 21:44
  • Commodore 64! :D -- too bad we can't include the symbols that go on the sides of the keys. Commented May 17, 2017 at 0:04
  • Commodore 64, sponsored by Retrocomputing. shameless-advertising
    – wizzwizz4
    Commented Oct 28, 2017 at 19:02
  • 2
    @TimPost Could have been VIC-20, I don't think keyboards were different. Also... function keys give it away? Sure, they were pretty distinctive... but how about the C= key? :D
    – Amadan
    Commented Oct 29, 2018 at 10:41
39

I saw this in an answer once
and have been baffled about how it worked
ever since then. But I
guess I know now.
I'm terribly sorry about this

it looks like a label maker

1
  • 39
    Now it looks like Messages on the iPhone...
    – Cody Gray
    Commented May 9, 2012 at 8:09
38

Am I late?


esc F1 F1 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10

~` !1@2 #3$4 %5^6 &7*8 (9)0 _-+=                 delete

tab                    Q W E R T Y U I O P {[ }]    |\   
caps lock           A S D F G H J K L :; "' return  
shift                       Z X C V B N M , >. ?/        shift
control ⌥ alt option cmd                              cmd alt ⌥  option ⌃ control

 
(based off of my keyboard)

0
35

I had no idea you could even do this, but now that I know, I want to do it everywhere!!!

Ins HomePgUp

Del End PgDn

           ↑  

  ←  ↓   →  

2
  • 45
    If only that were an actual key on my keyboard...
    – Eric
    Commented Jul 2, 2009 at 19:20
  • 6
    +1 for echoing my thought exactly!
    – Kip
    Commented Jul 2, 2009 at 20:01
23
          I 

       am ok

     w  i t  h 

  t   h   i   s  

22

Eliminating this is an affront to Emacs users everywhere. They will then delete SO with:

Ctrl + End + Del + S + O + F8

2
  • 26
    False! There is no way there is an emacs keybinding for that without Meta, Super and/or Hyper.
    – derobert
    Commented Sep 6, 2009 at 9:52
  • 2
    @Dimension1n0 Serves you right for trying to delete the Stack Exchange flagship site! >:-(
    – wizzwizz4
    Commented Oct 28, 2017 at 19:04
4

If you have an older Mac keyboard (just for , of course):

escF1F2F3F4F5F6F7F8F9F10F11F12F13  F14  F15   F16  
 `  1  2  3  4  5  6  7  8  9  0  -  = delete         help  homepgup
tab    Q  W  E  R  T  Y  U   I   O  P  [  ]  \       ⌫    end  pgdn
caps    * A  S  D  F  G  H  J  K  L  :  ' return      
shift            Z  X  C  V  B  N  M  ,  .   /    shift                            ▲  
ctrl                                                                                   ctrl    ◄     ▼    ▶   

 - +x⏏︎
= / 
89 - 
56
23   
0         . 

Not the answer you're looking for? Browse other questions tagged .