14
Background
You've been given a task to take notes for a meeting. You start typing on your Google Doc, but you don't have enough time during the meeting to look at your keyboard while you type.
Fortunately for you, you can type without looking at your keyboard. After the meeting, you realize that everything you typed was one key to the left.
The Challenge
For this challenge, you will be using the letters, numbers, and space bar of the QWERTY keyboard layout.
Given an input of text (from any standard input method), output the resulting text, where every character is moved one to the left on the keyboard.
For the majority of letters, just look at the letter and translate it to the letter to the left (
c
becomesx
,t
becomesr
, etc).For letter
q
, translate to a literal tab character (\t
).For letter
a
, enable caps lock, so the capitalization of the rest of the string is reversed.For letter
z
, capitalize the next letter in the string.No translation is required for the space bar.
Preserve capitalization while translating, and be mindful of caps lock (if caps lock is enabled, make sure the case is the opposite).
All characters in the input string will be letters, numbers, or a space. No punctuation or other characters can be included.
Test Cases
\t
is a literal tab character
Hello world -> Gwkki qieks
Code Golf -> Xisw Fikd
Queried apples -> \tyweuws OOKWA
Scoring
Lowest score in bytes wins. Have fun!
11A quick reference of the relevant rows of the QWERTY keyboard would be useful, and keep the challenge self-contained – Jo King – 2019-10-09T01:17:19.273
4Do numbers get shifted up to punctuation if there was a "Z" prior to them? – ErikF – 2019-10-09T01:27:04.313
@ErikF No, because caps lock does not do that on most common keyboard that I'm aware of. – connectyourcharger – 2019-10-09T01:29:12.600
10But Z corresponds to shift...? – Unrelated String – 2019-10-09T01:34:05.743
4Suggested test case:
Azerty
->wERT
– Jitse – 2019-10-09T07:28:23.6033Suggested test cases:
a123 -> \
12;
z123 -> ~12` – Jitse – 2019-10-09T07:41:11.9273Suggested test case with multiple A and a Z:
All zodiacs -> KK iSUxa
– Jitse – 2019-10-09T07:52:22.8575For letter
z
, capitalize the next letter in the string -> does that mean that we only have to care about letter capitalization and don't have to toggle between digits and symbols? What's the expected output for0123456789
,a0123456789
andz0z1z2z3z4z5z6z7z8z9
? (Besides, on many non-QWERTY keyboards, 'Caps Lock' really acts as a 'Shift Lock'. I believe that QWERTY doesn't follow this pattern, but it should be specified for those of us who are not familiar with it.) – Arnauld – 2019-10-09T09:02:27.6731The question could do with explicit clarification of the expected behaviour for
1
. My keyboard would result inz123 -> ¬12
, and not tilde. (Assuming the answer to @ErikF's question isYes
) – Wernisch – 2019-10-09T09:33:20.1832
Possible duplicate of Given an input, move it along the keyboard by N characters
– None – 2019-10-09T09:35:57.5272In fact, the Shift behaviour of all Numbers needs defining. My keyboard has:
¬!"£$%^&*()
@Matthew Jensen has~!@#$%^&*()
– Wernisch – 2019-10-09T09:38:39.8804What will happen if input contains two
z
in a row like:zze
? Should it outputW
orw
? – tsh – 2019-10-09T09:43:31.550