Given an input, move it along the keyboard by N characters The Challenge:

Given any input that can be typed on a keyboard, move the text along by N chars.

Here is the QWERTY keyboard to be used. You can ignore the modifier keys (Shift, Caps, Enter, Delete and Tab). Once you reach one side (for example |) loop back round, so | goes to Q if N = 1.



Spaces do not have to be moved along (they go back round to space as you skip modifiers). If shift was used to type the character (e.g. ! and @) the changed character should also be typed using shift (i.e. ! goes to @ not 2 if N = 1).

UK keyboards are different to this, but please use this so that we can compare.

Input:

Any sentence that can be typed on the above keyboard followed by a positive integer. There is no maximum to the size of this integer.

Output:

The same sentence, shifted along by N.

Examples:

My name is Tim 3
?o .f/y [g I[/




Hello World 7
Spgge Oe[g;




I Wi5h I h4d b3773r C@d3ing ski{{s 3
{ T[8l { l7h ,6006u N%h6[.k g'[QQg


This is code golf, so shortest code wins.
C, 217 bytes

char*t=" @A$%^*a)_(~.=/z-234567890\"'&gt;`?Z#SNVFRGHJOKL:&lt;MP{WTDYIBECUX]q\\&amp;=1snvfrghjokl;,mp[wtdyibecux}Q|!";l,d,k;f(char*s){for(l=strlen(s);s[--l]-32;);d=atoi(s+l);for(s[l]=0;d--;)for(k=l;k--;s[k]=t[s[k]-32]);puts(s);}


Readable version with whitespace, includes, etc:

#include &lt;string.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;

char* t = " @A$%^*a)_(~.=/z-234567890\"'&gt;`?Z#SNVFRGHJOKL:&lt;MP{WTDYIBECUX]q\\&amp;=1snvfrghjokl;,mp[wtdyibecux}Q|!";
int l, d, k;

void f(char* s) {
    l = strlen(s);
    for( ; s[--l] - 32; );
    d = atoi(s + l);
    s[l] = 0;
    for ( ; d--; ) {
        for (k = l; k--; s[k] = t[s[k] - 32]);
    }
    puts(s);
}


The code pretty much speaks for itself. Just a lookup table that maps from each character to the next character, which is applied the given number of times. Much of the code is actually for parsing the number out of the input.