[Question]
  [
Given the following input:
* An integer `n` where `n > 0`.
* A string `s` where `s` is not empty and `s~=[0-9A-Z]+` (alpha-numeric capitals only).
Using a standard, simplified QWERTY keyboard (as shown below):
```
1234567890
QWERTYUIOP
ASDFGHJKL
ZXCVBNM
```
Perform the following operation:
* Find the original row that each character is in on the keyboard.
* Replace the letter with the correct shifted equivalent for `n` based on its original position + n.
	+ E.G. `s="AB"` and `n=2`: `A` would become `D` and `B` would become `M`.
* If `keyboard_row[position + n] > keyboard_row.length`, wrap back to the start.
	+ E.G. `s="0P"` and `n=2`: `0` would become `2` and `P` would become `W`.
# Examples:
```
f("0PLM",1)    = 1QAZ
f("ZXCVB",2)   = CVBNM
f("HELLO",3)   = LYDDW
f("0PLM",11)   = 1QSV
f("0PLM",2130) = 0PHX
```
# Rules
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), lowest byte-count wins.
---
*This is slightly more difficult than it seems at first glance.*
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 13 bytes
```
ØQØDṭ,ṙ€¥⁸F€y
```
[Try it online!](https://tio.run/##y0rNyan8///wjMDDM1we7lyr83DnzEdNaw4tfdS4ww3IqPx/eLmRfuT//4Y6CkoGAT6@SjoKRkBmVIRzmBOQbQxke7j6@PgD2YbIagyNDWA8AA "Jelly – Try It Online")
### How it works
```
ØQØDṭ,ṙ€¥⁸F€y  Main link. Left argument: n (integer). Right argument: s (string)
ØQ             Qwerty; set the return value to
               ["QWERTYUIOP", "ASDFGHJKL", "ZXCVBNM"].
  ØD           Digits; yield "0123456789".
    ṭ          Tack, yielding ["QWERTYUIOP", "ASDFGHJKL", "ZXCVBNM", "0123456789"].
        ¥⁸     Call the two links to the left as a dyadic chain, with right
               argument n.
      ṙ€       Rotate each string in the array n units to the left.
     ,         Yield the pair of the unmodified and the rotated string array.
          F€   Flatten each, mapping, e.g., ["QWERTYUIOP", ..., "0123456789"] to
               "QWERTYUIOPASDFGHJKLZXCVBNM0123456789".
            y  Translate s according to the mapping we've built.
```
[Answer]
# [Python 2](https://docs.python.org/2/), 110 bytes
```
lambda s,n,y='1234567890'*99+'QWERTYUIOP'*99+'ASDFGHJKL'*99+'ZXCVBNM'*99:''.join(y[y.find(c)+n%630]for c in s)
```
[Try it online!](https://tio.run/##TY9Lb8IwEITv/Apfqk3KFuXRAkFyJWgoaTHl1fIKOVAgahB1UGwO@fVpHPfAbecbze7sJZc/KXeKmG6L8@73@7AjAjnmFGzHfXxqttqeBfeeV4fpsj/7XH@9jSdad@f@6yB4HzItN6uXRe9jpEQHoHFKE27kYd6IE34w9mad3zVdK4rTjOxJwokwC3kUUtCwFoI1YSNAG8GedjcQYYmqdYAOgl5bwaDP2BjQRWBr319q@B@u0vPFLXNs18JyDlaKRjV1XD2XHcX1LFWLqkLnkiVcktgoPZNS7SIJSxkhPDwDaqv4Aw "Python 2 – Try It Online")
This uses a big enough string (99 copies of each row) and the LCM between the rows lengths (630) to find the correct substitution avoiding individual correction between each row.
[Answer]
# Java 8, ~~159~~ 158 bytes
```
n->s->{for(int i=s.length,j;i-->0;)for(String x:"1234567890;QWERTYUIOP;ASDFGHJKL;ZXCVBNM".split(";"))if((j=x.indexOf(s[i])+n)>=n)s[i]=x.charAt(j%x.length());}
```
-1 byte thanks to *@OlivierGrégoire* modifying the input-array instead of printing directly.
**Explanation:**
[Try it online.](https://tio.run/##bVHbTsJAEH33KzZNTHZjuwHxvtIEEa9FULwTHtaywGKZNt2tlhi@vW5xE8WQzMPkzJmZM2em/IN7cSJgOnwvwogrhdpcwtcGQkpzLUM0NQyaaRnRUQahljHQM5scX4IWY5G660jNGFQ2E@lxOOFpf@D7KER1VIDnK8//GsUplqCRrCsaCRjricuZ9Dy/wkhZ6@lUwhjlR051u7azu7d/cFhht0@tu/uXh8tOlzV6p2fnF1fXAXt9bj6e3LQdqpJIauwwhxA5wpjXcyphKPLOCKu@HJAtIH4dSJmbUqmqoTHfzO1@TAhbFMwcbiLJ3iJzu7XgI5ZDNDO2WFn9ASelQwhpoTTedp3GiUPYClLpriDVEgna/1lL8StgzXUuWkHQWe1e216tVf7Ci43fpy0VL1mlyeAi66eyun9@grj5iKI6bpZmpCmfY7sgpDxJojkGQnkYisQYZSu9udJiRuNM08SM1BFgEJ92vmFZKYviGw)
```
n->s->{  // Method with integer and character-array parameters, and no return-type
  for(int i=s.length,j;i-->0;)
         //  Loop over the input character-array with index
    for(String x:"1234567890;QWERTYUIOP;ASDFGHJKL;ZXCVBNM".split(";"))
         //   Inner loop over the qwerty-lines
      if((j=x.indexOf(s[i])+n)>=n)
         //    If the current qwerty-line contains the character
         //     Set `j` to the index of this character on that line + input `n`
        s[i]=x.charAt(j%x.length());}
         //     Replace the character at index `i`
         //     with the new character (at index `j` modulo length_of_qwerty_line)
```
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 49 bytes
```
"$&"+T`9o`dQW\ERTYUI\OPQASDFG\HJK\LAZXC\VBNMZ
0A`
```
[Try it online!](https://tio.run/##K0otycxLNPz/X0lFTUk7JMEyPyElMDzGNSgkMtQzxj8g0DHYxc09xsPLO8bHMSrCOSbMyc83isvAMeH/f2MuD1cfH38A "Retina – Try It Online") Takes input `n` and `s` on separate lines. Explanation:
```
"$&"+
```
Repeat `n` times.
```
T`9o`dQW\ERTYUI\OPQASDFG\HJK\LAZXC\VBNMZ
```
Shift all the characters one key to the right.
```
0A`
```
Delete `n`.
[Answer]
# JavaScript (ES6), ~~101~~ 99 bytes
Takes input in currying syntax `(s)(n)`. Works with arrays of characters.
```
s=>n=>s.map(c=>(S='1QAZ2WSX3EDC4RFV5TGB6YHN7UJM8IK_9OL_0P')[(p=S.search(c)+n*4)%(-~'9986'[p%4]*4)])
```
### Test cases
```
let f =
s=>n=>s.map(c=>(S='1QAZ2WSX3EDC4RFV5TGB6YHN7UJM8IK_9OL_0P')[(p=S.search(c)+n*4)%(-~'9986'[p%4]*4)])
console.log(JSON.stringify(f([..."0PLM"])(1)))    // 1QAZ
console.log(JSON.stringify(f([..."ZXCVB"])(2)))   // CVBNM
console.log(JSON.stringify(f([..."HELLO"])(3)))   // LYDDW
console.log(JSON.stringify(f([..."0PLM"])(11)))   // 1QSV
console.log(JSON.stringify(f([..."0PLM"])(2130))) // 0PHX
```
### How?
We look for the position **p** of each character of the input within a string **S** where the keyboard rows are interleaved: the first 4 characters are **'1QAZ'** (first column of the keyboard), the next 4 characters are **'2WSX'** (second column of the keyboard) and so on. Unused positions are padded with underscores and the last ones are simply discarded.
```
col # | 0    | 1    | 2    | 3    | 4    | 5    | 6    | 7    | 8    | 9
------+------+------+------+------+------+------+------+------+------+---
row # | 0123 | 0123 | 0123 | 0123 | 0123 | 0123 | 0123 | 0123 | 0123 | 01
------+------+------+------+------+------+------+------+------+------+---
char. | 1QAZ | 2WSX | 3EDC | 4RFV | 5TGB | 6YHN | 7UJM | 8IK_ | 9OL_ | 0P
```
This allows us to easily identify the row with **p mod 4** and eliminates the need for explicit separators between the rows.
We advance by **4n** positions, apply the correct modulo for this row (40, 40, 36 and 28 respectively) and pick the replacement character found at this new position in **S**.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 18 bytes
```
ØQØDṭẋ€‘}Ẏ©iÐ€⁸+ị®
```
[Try it online!](https://tio.run/##y0rNyan8///wjMDDM1we7lz7cFf3o6Y1jxpm1D7c1XdoZebhCSBu4w7th7u7D637//@/kkGAj6/Sf0MA "Jelly – Try It Online")
[Answer]
# C, ~~152~~ 149 bytes
*Thanks to @gastropner for saving three bytes!*
```
j,l;f(S,n){for(char*s=S,*k;*s;++s)for(k="1234567890\0QWERTYUIOP\0ASDFGHJKL\0ZXCVBNM\0";l=strlen(k);k+=l+1)for(j=l;j--;)k[j]-*s||putchar(k[(j+n)%l]);}
```
[Try it online!](https://tio.run/##dY1dT8IwGIXv@RWkiUnftUvaTUTzphd@oChD0PnNuCCLU9pazDqvgN8@B5E7PJfPk3NOHn7keV1rbrGgKXewLBYlzT9nZeBVygODgUfGPGywUURG8WHnqHt8IjJx99y7f3h9vB6NM3GaXlxe9W8GSSbeXs6fzm6HmSBola9K@@6oATRMWSa3O1pZ1GGIYCZ6GgZ@tfr@qTaf1EyoZg4O7BRwXc9d1f6azR2F1rLVblJQIsbJkHAJ2FQ8JQRwZ7a/hEd7VL@XJCPC4z3qb0/@qyIZi4at618)
**Unrolled:**
```
j,l;
f(S,n)
{
    for (char*s=S, *k; *s; ++s)
        for (k="1234567890\0QWERTYUIOP\0ASDFGHJKL\0ZXCVBNM\0"; l=strlen(k); k+=l+1)
            for (j=l; j--;)
                k[j]-*s || putchar(k[(j+n)%l]);
}
```
[Answer]
# [Red](http://www.red-lang.org), 152 bytes
```
f: func[s n][foreach c s[foreach[t l]["1234567890"10"QWERTYUIOP"10"ASDFGHJKL"9"ZXCVBNM"7][if p: find t c[if(i:(index? p)+ n // l)= 0[i: l]prin t/(i)]]]]
```
[Try it online!](https://tio.run/##dY1NT8JAGITv/IrJe2rjobutCm1CDGoFtQjyIehmD6bdDZs0a1Nq4N@XxcCJOKd58iQztSramSogZKsT6F@biy2sFPqnVt/5Bjm25y4alFIQD6Prm9tuL2bEGb2v0tnic/k8mR5pMH98Go5eXjOK6Wv98HH/NqauFEajcuPGFmiQO/RM4jlS@ztU/hUsggCl3wcTJnEnVW0smsAzvnRpNYhNszGBd46mgVW70ljVceLvhRBemlGaZRNCBFy60xz/z4Q8Yu0B "Red – Try It Online")
Ungolfed:
```
f: func [s n][1
    foreach c s [
        foreach [t l] ["1234567890"10"QWERTYUIOP"10"ASDFGHJKL"9"ZXCVBNM"7][
            p: find t c
            if p [ 
                i: (index? p) + n // l
                if i = 0 [i: l]
                prin t/(i) ]]]]
```
[Answer]
# [Haskell](https://www.haskell.org/), 99 bytes
```
f(s,n)=[dropWhile(/=c)(cycle r)!!n|c<-s,r<-words"1234567890 QWERTYUIOP ASDFGHJKL ZXCVBNM",elem c r]
```
[Try it online!](https://tio.run/##DcnbCoIwAADQX5k@bTDJaVfQh@43K7taiQ8yJ0pzyhZE4L@vzuspUvVinGudQ4UF8uNM1k1UlJzBjk8RpF/KGZDIMERLPUth6VmfWmbKJI7b7fUHw5ENjtH8dHlc14cQjM@zxXK12QbgeZ/eJvudiRlnFaBAJrpKS@E3shTvOIemHQb/FagVnhUTTAh2iGsnif4B "Haskell – Try It Online")
[Answer]
# [Perl 5](https://www.perl.org/), 94 + 1 (`-p`) = 95 bytes
```
$s=<>;for$i(1234567890,QWERTYUIOP,ASDFGHJKL,ZXCVBNM){eval"y/$i/".(substr$i,$s%length$i)."$i/"}
```
[Try it online!](https://tio.run/##K0gtyjH9/1@l2NbGzjotv0glU8PQyNjE1MzcwtJAJzDcNSgkMtTTP0DHMdjFzd3Dy9tHJyrCOczJz1ezOrUsMUepUl8lU19JT6O4NKm4BKhdR6VYNSc1L70kQyVTU08JJFn7/79BgI8vl5GhscG//IKSzPy84v@6vqZ6BoYG/3ULAA "Perl 5 – Try It Online")
[Answer]
# Japt, 20 bytes
Running out the door to dinner so more golfing and an explanation to follow.
```
;£=D·i9òs)æøX)gV+UbX
```
[Try it](https://ethproductions.github.io/japt/?v=1.4.5&code=O6M9RLdpOfJzKeb4WClnVitVYlg=&input=IjBQTE0iLDIxMzA=)
[Answer]
# Perl, ~~59~~ ~~58~~ ~~57~~ 56 bytes
Includes `+` for `-p`
Give input on STDIN as 2 lines, first the string, then the repeat
```
(echo 0PLM; echo 2130) | perl -pe '$a="OPQWERTYUILASDF-MZXCVBNM0-90";eval"y/HI$a/J$a/;"x<>'
```
[Answer]
# [Perl 5](https://www.perl.org/), 85 bytes
**84 bytes code + 1 for `-p`.**
```
eval join"",map"y/$_/@{[/./&&$'.$&]}/;",(1234567890,QWERTYUIOP,ASDFGHJKL,ZXCVBNM)x<>
```
[Try it online!](https://tio.run/##K0gtyjH9/z@1LDFHISs/M09JSSc3sUCpUl8lXt@hOlpfT19NTUVdT0UttlbfWklHw9DI2MTUzNzC0kAnMNw1KCQy1NM/QMcx2MXN3cPL20cnKsI5zMnPV7PCxu7/f4MAH18uQy6wGJcRl4erj48/lzEXRNgQQhsZGhtw/csvKMnMzyv@r1sAAA "Perl 5 – Try It Online")
[Answer]
# [Clean](https://clean.cs.ru.nl), ~~144~~ 119 bytes
```
import StdEnv
```
# 
```
\n s=[l.[(i+n)rem(size l)]\\c<-s,l<-["1234567890","QWERTYUIOP","ASDFGHJKL","ZXCVBNM"],i<-[0..]&j<-:l|j==c]
```
[Try it online!](https://tio.run/##S85JTcz7n5ufUpqTqpCbmJn3PzO3IL@oRCG4JMU1r@x/cEliUQmXskKagq1CTJ5CsW10jl60RqZ2nmZRaq5GcWZVqkKOZmxMTLKNbrFOjo1utJKhkbGJqZm5haWBko5SYLhrUEhkqKd/AJDjGOzi5u7h5e0DZEdFOIc5@fkqxepkAjUZ6OnFqmXZ6Frl1GTZ2ibHctkCLTRWiFb3cPXx8VeP/f8vOS0nMb34v66nz3@XyrzE3MxkCAfoTJ/MJAA "Clean – Try It Online")
Lambda function with the signature `Int ![Char] -> [Char]`
[Answer]
# [Ruby](https://www.ruby-lang.org/), 101 bytes
```
->s,n{n.times{s.tr! '1234567890QWERTYUIOPASDFGHJKLZXCVBNM','2345678901WERTYUIOPQSDFGHJKLAXCVBNMZ'};s}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf165YJ686T68kMze1uLpYr6RIUUHd0MjYxNTM3MLSIDDcNSgkMtTTP8Ax2MXN3cPL2ycqwjnMyc9XXUcdrsoQrioQpsoRoipKvda6uPZ/NJeCQrSSQYCPr5KOYawOmAc2R0nHCMr1cPXx8VfSMYZyoWoNUbhGhsYGsVyxeqmJyRkKKfkKNcU6CkU1QAUFpSXFCml6yYk5OQogMa7UvJT/AA "Ruby – Try It Online")
I'm honestly a little disappointed that I couldn't do better with 'cleverer' methods. The closest I got was along the lines of
```
a=%w{1234567890 QWERTYUIOP ASDFGHJKL ZXCVBNM}
b=a.map{|r|r[1..-1]<<r[0]}*''
a*=''
n.times{s.tr! a,b}
```
for a net gain of 7 characters.
]