g | x | w | all
Bytes Lang Time Link
3945Uiua240710T041119ZOmnikar
nansed has a command specifically for this that I rarely get to use240709T212138Zguest430
138Go240709T185634Zbigyihsu
013Jelly210701T212900Zcaird co
01305AB1E210818T083713ZKevin Cr
012Vyxal210702T044805Zemanresu
035Pyth210705T033516ZScott
080PHP210704T172524ZAdam P.
093Excel210703T143601ZAxuary
102Common Lisp210703T094636ZThun_A
065Haskell210702T124032ZWheat Wi
092C++ Windows MSVC210702T025647Ztsh
079C gcc210702T051404ZErikF
114PHP210702T161443ZSlamJamm
059Haskell210702T185943Zlynn
055R210702T140602Zpajonk
057Perl 5210702T120320ZKjetil S
036Charcoal210702T094757ZNeil
066JavaScript ES6210701T225237ZArnauld
401Ruby p210702T061424ZG B
029Japt m210702T024152ZAZTECCO
064C# Visual C# Interactive Compiler210702T011619ZGymhgy
036Retina 0.8.2210701T232438ZNeil
034Bash210701T232651ZNeil
061Python 3210701T232058Zdingledo
043J210701T220107ZJonah

Uiua, 39 characters/45 bytes

⊏+1⊸⊗:"  ,mnbvcxz;lkjhgfdsa[poiuytrewq"

Try it online

" ,mnbvcxz;lkjhgfdsa[poiuytrewq" is the entire keyboard, plus the shifted characters, plus two spaces, written in reverse (explained later). This string is pushed to the stack first, then:

     : # Flip the top two stack values, placing the keyboard string under the input
   ⊸⊗  # Replace characters in the input with their indices in the keyboard string,
       # but keep the keyboard string underneath on the stack
 +1    # Add 1 to all the indices, shifting left in the keyboard string
⊏      # Select all the indices in the resulting array from the keyboard string

searches the haystack string from the left, which means that spaces will get replaced with the index of the first space, meaning the index must be +1'd to shift it to the second space. For this reason, the rest of the keyboard string is written in reverse so that +1 acts as a leftward shift.

sed has a command specifically for this that I rarely get to use, so:

sed, 56 bytes

y/wertyuiop[sdfghjkl;xcvbnm,/qwertyuiopasdfghjklzxcvbnm/

Try it online!

the 'y' command maps letters matching the first string to their position in the second

Go, 138 bytes

import."strings"
func f(s string)(o string){M:=`,mnbvcxz;lkjhgfdsa[poiuytrewq  `
for _,r:=range s{i:=IndexRune(M,r)+1
o+=M[i:i+1]}
return}

Attempt This Online!

Go, 142 bytes

import."strings"
func f(s string)string{M:=`,mnbvcxz;lkjhgfdsa[poiuytrewq  `
return Map(func(r rune)rune{return rune(M[IndexRune(M,r)+1])},s)}

Attempt This Online!

Both solutions use the same keyboard mapping found by other users. Amazing how the solution using the manual loop is only 4 bytes shorter than using the stdlib approach.

Jelly, 15 13 bytes

Øqż“[;,”FUƝFy

Try it online!

-1 byte directly from emanresu A, and minus a second byte from a golf of that suggestion.

How it works

This exploits the leading constant chain structure in Jelly, wherein if a chain begins with a constant (Øq in this case), and is followed exclusively by monads and dyad-nilad pairs, the chain simply operates on the leading constant, ignoring any provided arguments, until this pattern is broken, saving us from having to use any grouping quicks while we construct the translation mapping.

Øqż“[;,”FUƝFy - Main link. Takes the string S on the left
Øqż“[;,”FUƝF  - Leading constant chain:
Øq            -   Constant: “qwertyuiop“asdfghjkl“zxcvbnm”
  ż“[;,”      -   Dyad-nilad: Zip with “[;,”
        F     -   Monad: Flatten; “qwertyuiop[asdfghjkl;zxcvbnm,”
         UƝ   -   Monad:
          Ɲ   -     Over overlapping pairs:
         U    -       Reverse
           F  -   Monad: Flatten; “wqewretrytuyiuoipo[pa[sadsfdgfhgjhkjlk;lz;xzcxvcbvnbmn,m”
            y - With the transliteration string on the left and S on the right, transliterate S according to the string

The way Jelly's transliterate atom, y, works when provided a flat string on the left is to break it up into adjacent pairs of characters, then replace the first character with the second in the target string on the right. So “wqewretrytuyiuoipo[pa[sadsfdgfhgjhkjlk;lz;xzcxvcbvnbmn,m”y transliterates

w -> q
e -> w
r -> e
...
, -> m

05AB1E, 13 bytes

žV€¦…[;,øSžW‡

Try it online.

Explanation:

žV            # Push builtin ["qwertyuiop","asdfghjkl","zxcvbnm"]
  €¦          # Remove the first character from each: ["wertyuiop","sdfghjkl","xcvbnm"]
    …[;,ø     # Zip/transpose with string "[;,":
              #  [["wertyuiop","["],["sdfghjkl",";"],["xcvbnm",","]]
         S    # Convert it to a flattened list of characters: 
              #  ["w","e","r","t","y","u","i","o","p","[","s","d","f","g","h","j","k",
              #   "l",";","x","c","v","b","n","m",","]
          žW  # Push builtin "qwertyuiopasdfghjklzxcvbnm"
            ‡ # Transliterate all characters in the (implicit) input
              # (after which the result is output implicitly)

Vyxal, 16 13 12 bytes

k•`[;,`Y∑:ǔĿ

Try it Online!

k•           # Qwerty keyboard (array of rows)
  `[;,`Y     # Interleave with `[;,`
        ∑    # Concatenate all of that
         :ǔĿ # Shift each character 1 right relative to this in the input.

Pyth, 45 35 bytes

.rQ"[poiuytrewq;lkjhgfdsa,mnbvcxz  

Try it online!

sm?gJtxK.",zcVÖzùwÔ\"Ã?4‰ØÝ”gR¹³3"dZ@KJ\ Q

Try it online!

*Edit: Improved solution is rather boring...
"[poiuytrewq;lkjhgfdsa,mnbvcxz is a string of every possible char followed by the char it's meant to be (i.e. ytrewq) with two spaces on the end (space is meant to be space);

This is all surrounded with .r which will translate each element of Q(Input) into the next element.

Previous solution
Haven't golfed in a while so this feels pretttty rusty...

Maps through qwerty string, shifting char to the left unless it's a space.

PHP, 80 bytes

str_replace($a=str_split('wertyuiop[asdfghjkl;yxcvbnm,'),[-1=>'q']+$a,$argv[1]);

Avoids string repetition and double str_split().

Try it online!

Excel, 93 bytes

=CONCAT(IFERROR(CHAR(FIND(MID(A1,SEQUENCE(LEN(A1)),1),"snvfrghjokl;,mp[wtdyibecux")+96)," "))

Link to Spreadsheet

Common Lisp, 102 bytes

(defun f(i &aux(s",mnbvcxz;lkjhgfdsa[poiuytrewq  "))(map'string(lambda(c)(elt s(1+(position c s))))i))

Try it online!

Test cases included in TIO.

Haskell, 65 bytes

a#(c:d)|a==c=d!!0|1>0=a#d
map(#",mnbvcxz;lkjhgfdsa[poiuytrewq  ")

Try it online!

(#) takes a character and a string and returns the character after the first match in the string. Our implementation then just maps this across the string with ,mnbvcxz;lkjhgfdsa[poiuytrewq as the preset string.

C++ (Windows MSVC), 92 bytes

#include<Windows.h>
void f(PCH s){for(;*s;)*s++=MapVirtualKey(OemKeyScan(*s)-(*s>32),1)|32;}

Take input as a char* (PCH is typedef of char*), output by modify the string in-place.

Trying to make use of some built-ins. But seems not quite short. Maybe some one may take this idea and make a shorter one in other languages.

OemKeyScan convert key to its scancode, 'q' -> 16, 'w' -> 17, 'e' -> 18, ..., 'p' -> 25, 'a' -> 30, ..., 'l' -> 38, 'z' -> 44, ..., 'm' -> 50. MapVirtualKey convert scancode back to (uppercase) character.

Saved 1 byte by ErikF.

C (gcc), 79 bytes

I combined the source and destination strings so that I can take the character after the match. By inverting the list of characters, I could avoid -1 indexes and having to special-case spaces.

f(char*s){for(;*s;putchar(strchr(",mnbvcxz;lkjhgfdsa[poiuytrewq  ",*s++)[1]));}

Try it online!

PHP, 186 114 Bytes

$W=str_split(",mnbvcxz;lkjhgfdsa[poiuytrewq");for(;$c=$argv[1][$p++];)echo($c!==" ")?$W[array_flip($W)[$c]+1]:" ";

Try it online! Definitely not the shortest answer on here, but I'm not sure how I could handle this in PHP without using a big array. Any input would be greatly appreciated!

-72 bytes by changing a large keyed array into one small one. Just iterates over every character, find it in the array, then prints the next element in the array.

Haskell, 59 bytes

mapM(`lookup`(zip<*>tail)",mnbvcxz;lkjhgfdsa[poiuytrewq  ")

Try it online!

A function String -> Maybe String; it maps "s gom" to Just "a fin".

R, 68 55 bytes

function(x)chartr("snvfrghjokl;,mp[wtdyibecux","a-z",x)

Try it online!

Abusing laconic Ranges are supported in the specifications in chartr documentation (forced to work by try and error).

Inspired by @Neil's answer.

Perl 5, 57 bytes

s/./",mnbvcxz;lkjhgfdsa[poiuytrewq  "=~m|\Q$&\E(.)|;$1/ge

Try it online!

s/.                                  #replace one char at a time from input
 /
   ",mnbvcxz;lkjhgfdsa[poiuytrewq  " #...with its next char in this string
     =~ m| \Q$&\E (.)|x;             #found by searching for current char in $&
                                     #which must be escaped by \Q and \E
                                     #since [ has a special meaning in regexes.
   $1                                #Return next char captured into $1 by (.) 
 /gex                                #g = global search: all chars
                                     #e = treat replacement string as eval code
                                     #x = allow white-space, improve readability

Charcoal, 36 bytes

≔”⧴3�⁷Rrηs⟲θ]⁺L÷↗¹T“[~↓TφF”η⭆S§η⊕⌕ηι

Try it online! Link is to verbose version of code. Explanation: Port of @ErikF's C answer, except putting the spaces at the beginning because that compresses better.

≔”⧴3�⁷Rrηs⟲θ]⁺L÷↗¹T“[~↓TφF”η

Assign the compressed string ,mnbvcxz;lkjhgfdsa[poiuytrewq to a variable.

⭆S§η⊕⌕ηι

Find each input character in the string and print the character that follows it.

JavaScript (ES6), 66 bytes

I/O format: array of characters.

a=>a.map(c=>(S="  ,mnbvcxz;lkjhgfdsa[poiuytrewq")[S.indexOf(c)+1])

Try it online!


JavaScript (ES6), 57 bytes

If taking an array of ASCII codes as input and returning an array of characters is acceptable, we can do:

b=>b.map(c=>"rjbwgtvacnofh_spzleykidumx_q "[c*19%116%30])

Try it online!

Ruby -p, 40+1 bytes

$_.tr!"snvfrghjokl;,mp[wtdyibecux","a-z"

Try it online!

Japt -m, 29 bytes

;D+S ·¬v gD·mÅí"[;,"¬'+ ¬v bU

Try it

; -> use second set of predef. Vars
-m flag -> map input by the program  (U)->

     g   - take from 
D+S·¬v     [ QWERTY +' ' split on (\n),rejoined, to lowercase ]
Dxxx bU  - at index of input in[WERTY..]

D·   - QWERTY split on \n
mÅ   - remove 1st char on each
í    - pair with :
"[;,"¬  - ..splitted
'+   - and join
¬v   - join all and to lowercase

C# (Visual C# Interactive Compiler), 64 bytes

x=>x.Select(t=>" mlpvxswdfguhjknbio?earycqzt"[t%94%88%57%43%32])

Try it online!

Retina 0.8.2, 36 bytes

T`snvfrg\hj\ok\l;,m\p[\wt\dyibecux`l

Try it online! Link includes test cases. Explanation: Simply a transliteration, although Retina's built-in classes need to be escaped on the source string (obviously the built-in class l is desired on the target string).

Alternative solution, also 36 bytes:

T`\wertyuio-p[as\df-hj-l;zxcvbnm,`qo

Try it online! Link includes test cases. Transliterates the letters in keyboard order. This costs bytes because a and z have to be included in the source list and q in the destination list but then bytes can be saved by using character ranges to avoid quoting the o, p, h and l character classes.

Bash, 34 bytes

tr snvfrghjokl\;,mp[wtdyibecux a-z

Try it online! Using bash because I don't know how to score this as a tr answer.

Python 3, 61 bytes

lambda s:s.translate('p?ml ??'*14+'vxswdfguhjknbio?earycqzt')

Try it online!

Explanation

A naive implementation with str.translate would use the following translation table:

???????????????????????????????? ???????????m??????????????l???????????????????????????????p??????vxswdfguhjknbio?earycqzt

To optimize for size, notice that the characters ' mlp' all have different positions, modulo 7. As such, we can replace the first 98 characters of the table with 'p?ml ??'*14. The rest of the table is the same.

J, 43 bytes

'qwertyuiop[asdfghjkl;zxcvbnm,  '(<:@i:{[)]

Try it online!