21
3
Code Golf Challenge
I have an isdue, my fingrrs are fat and I freqintly jave an isdue of ty[ing one keystrpke to the right on my kryboard.
I'm afraid the isdue is getyng worse anf worsr as time goes on.
Sopn every keystrpke I make wil; be shiftrd pne to the right!
Befpre then I'd like a program (or functipn) to autp shift every keystrpke back to the left one.
I'll make sure to take my tome typong the rest of tjis chal;enge so as not to cause anu confudion!
Objective:
Write a program or function that takes an input of one of the following green keys on a standard QWERTY keyboard and returns the character of the key one to the left of it.
Conditions:
•You may assume that the person running this program is using a QWERTY keyboard like the one pictured above.
•Input and Output are both case-insensitive, you may use any case (or a mixture of case combinations) for this challenge and you can also assume all input will be in one case if desired.
•If your language has no way of allowing a user to input the return key for some reason you may ignore that one keystroke for this
•This challenge is just for the default values of the keys, for example if the 4
key is pressed you can assume it will always be 4
and never $
•You can assume only the green keys will ever be pressed.
Example Input
-> Output
:
S
-> a
4
-> 3
=
-> -
[
-> p
This is code-golf, so the program with the shortest bytecount wins!
Could you provide testcases? – user41805 – 2017-02-24T11:05:37.290
1@KritixiLithos Certaimly! I'll edit tjat in now@ – Albert Renshaw – 2017-02-24T11:06:35.357
Did you mean
]
->[
? – shooqie – 2017-02-24T11:22:03.990@shooqie fixrd! – Albert Renshaw – 2017-02-24T11:22:28.710
Do we need to provide functionality for backspaces? – Okx – 2017-02-24T11:25:27.767
@Okx No thats npt a green key@ (in my imsge) – Albert Renshaw – 2017-02-24T11:26:13.260
3related – Rod – 2017-02-24T11:28:42.513
3You might not care, but here's an interesting piece of trivia: this is an ANSI keyboard layout. Note the backslash above the Enter key; in contrast to an ISO keyboard, in which the backslash button is to the left of Z. (It's also American, but that's easier to identify!) – Doddy – 2017-02-24T16:59:30.317
@Doddy ah nice to know. I was wondering why the Enter key was cut in half. – Andrea Lazzarotto – 2017-02-24T19:19:00.077
I can see no green keys on the image, only black keys overlaid with green circles. – John Dvorak – 2017-02-25T14:36:31.690
@Doddy On my work keyboard the
|\
key is used twice for some reason.. Left of theZ
as you said, but another one between the'"
andENTER ↵
, which I usually use. Didn't even knew one was right of theZ
before.. xD – Kevin Cruijssen – 2017-08-18T07:16:47.837