##JS, 303##303, 288, 275, 273##
function z(s){return s.split('').map(function(d){if((r=Math.random)(b='qwertyuiop0asdfghjkl000zxcvbnm')>.1)return d
if((c=r(x=(d>'`'?b:(b=b.toUpperCase())).search(d))*(/[a-z]/i.test(d)+3))<2)return c>1?d+d:''
for(a=0;!a;)a=b[x+[11,-11,1,-1][~~(r()*4)]]
return a}).join('')}
function z(s){return s.split('').map(function(d){if((r=Math.random)()>.1)return d
if((c=r()*(/[a-z]/i.test(d)?3:2))<2)return c>1?d+d:''
if((x=(b="qwertyuiop0asdfghjkl000zxcvbnm").indexOf(d))<0)x=(b=b.toUpperCase()).indexOf(d)
for(a=0,n=11;i=!a;a=b[x+n])for(v=r()*4;v>i;n=i++%2?-n:1);return a}).join('')}
function z (s) {
return s.split('') // split input string into characters.
.map( // and then for each character...
function (d) {
r = Math.random; // set up a shortened form of Math.random
// declare keyboard here because we have parens and we can save a delimeter.
b = 'qwertyuiop0asdfghjkl000zxcvbnm';
if (r() > .1) { // normal case
return d;
}
numOptions = /[a-z]/i.test(d) ? 3 :+ 2;3; // if it's a character, three0+3, else -1+3 options
c =// r()test *here numOptions;because //we charshave canparens. bex 0-3,might non-chars:be 0-21
if (cd < 2> '`') {
x = b.search(d); // x marks //the thisspot
case is simple, so it comes} firstelse {
returnb c>1= ?b.toUpperCase();
d + d : ''; // double orx omit= b.search(d);
}
c = r() * numOptions; // wechars mustcan be in0-3, keyslipnon-chars: mode.0-2
bif =(c "qwertyuiop0asdfghjkl000zxcvbnm";< 2) //{ keyboard map
x = b.indexOf(d); // x marks the spot
// this case is simple, so ifit (xcomes <first
0) { // not here? must be a capitalreturn letter!
c>1 ? d + d : ''; // bdouble =or bomit.toUpperCase();
}
x = b.indexOf(d);
// we must be in keyslip }mode.
// in the golfed code, thesethis while loopsloop become for loops,
// but it's really a while.
a = 0, n = 11, i = 1;0;
while (!a) { // that is, a != null && a != 0
i = 1;
v = ~~(r() * 4;4); // so v is a random number <= 4
while (v0, >1, i)2, {or 3
nnewX = i++ % 2 ? -n : 1; // n steps in thisx pattern:+ [11, -11, 1, -1]
1][v]; // choose }one
a = b[x+n];b[newX]; // slip the key
}
return a;
}
) // end the map function
.join('') // and then reassemble the string
}