Skip to main content
4 of 4
added 56 characters in body
Martin Ender
  • 198.3k
  • 67
  • 455
  • 999

CJam, 42 40 bytes

"wertyuiop asdfghjkl zxcvbnm"q/W=S%Sf*N* 

Test it here.

Explanation

"we...nm" e# Push the letters in order, without q. We don't need q, because it will never e# be part of the output. q/ e# Split the string around the input. If the input is "q", the entire string e# will go into a single chunk. W= e# Select the last chunk. S% e# Split the string around spaces, discarding empty segments (only relevant for the e# first segment if the input is "p" or "l"). Sf* e# Join each line by spaces. N* e# Join the lines by linefeeds. 
Martin Ender
  • 198.3k
  • 67
  • 455
  • 999