Sweet little piece of code!! I have already added it to my site. A slight problem I found during 'testing' though...
keywords = keywords.replace(/\W/g, ''); // removes any spaces
var str = keywords.split(" "); // uses spaces to split
If you want to separate the keywords string by finding 'spaces' (which is what the second line does), remove the first line.