39
1
Given any of the following characters (or a newline):
`1234567890-=~!@#$%^&*()_+qwertyuiop[]\QWERTYUIOP{}|asdfghjkl;'ASDFGHJKL:"zxcvbnm,./ZXCVBNM<>?
Your program must output the row that it is on the keyboard
Because my keyboard is (almost) out of battery, your code must be as short as possible
The keyboard your program should use (for the row lookup), should look like:
Row 1:~` !1@2 #3$4 %5^6 &7*8 (9)0 _-+=
Row 2: Q W E R T Y U I O P {[ }] |\
Row 3: A S D F G H J K L :; "' ↵ return
Row 4: Z X C V B N M <, >. ?/
Row 5: space
Where ↵ return is a newline. Empty keys don't mean anything.
Examples
"$"
1
"R"
2
"a"
3
"?"
4
"\n"
3
" "
5
where \n
is a newline character.
Specifications
- Your program should be case insensitive
- Your program only needs to handle the characters on the keyboard shown
3Perhaps [tag:classification]? – lirtosiast – 2016-01-07T01:42:35.857
3Is that a double-nested
kbd
? – Conor O'Brien – 2016-01-07T04:04:02.047I remember years ago using some language that returned keypresses as as 100×row+position... Would have been perfect for this, but unfortunately I don't remember what it was. Maybe some form of BASIC... – Adám – 2016-01-07T13:35:39.230
@NBZ Is it Blitz Basic? – wizzwizz4 – 2016-01-07T18:43:28.963
@wizzwizz4 No, sorry. – Adám – 2016-01-07T18:59:24.877
@NBZ Do you by any chance have a working copy of Blitz Basic? I have a trial that it is legal to distribute, but it has no debugger etc. and it deletes it's executables after it is executed etc. – wizzwizz4 – 2016-01-07T19:04:20.427
@wizzwizz4 No. I used to use various BASIC flavours as a kid, but now I exclusively program in APL (it's my job), and a little JavaScript when I have no choice. – Adám – 2016-01-07T19:09:44.110
@NBZ That comment just makes me sad. You don't have a copy of the now discontinued Blitz Basic, and you only use JavaScript when you have no choice?!? :-( – wizzwizz4 – 2016-01-07T19:13:38.057
@wizzwizz4 Have you ever used an APL language (J, K, Q...)? Once you get into it, using any other language feels very limiting. – Adám – 2016-01-07T19:50:15.177
ewww, QWERTY! :-( – Toby Speight – 2016-01-07T20:44:09.257
1@wizzwizz4 Have you tried BlitzPlus? it's free and looks like it's what you want. – HolyBlackCat – 2016-01-25T22:42:00.930
@HolyBlackCat Yes!!! Yes yes yes!!! Unfortunately, the original Blitz Basic software no longer exists, but BlitzPlus looks like the same programming language. Thank you! – wizzwizz4 – 2016-01-26T16:44:27.560
Related: A keyboard so real you can almost TASTE it
– sergiol – 2017-10-30T02:06:29.657can we return the row 0-indexed? – Brian H. – 2017-12-20T16:43:33.253