It worked!!! Here's the result:
var aInput = event.value.split(" "); // make an array split at space
var sCharacter = '';
var sWord='';
// for each element of word array, capitalize the first letter
for(i = 0; i <aInput.length; i++) {
aInput[i] = aInput[i].substr(0, 1).toUpperCase() + aInput[i].substr(1) .toLowerCase();
} // end loop for input string
// rebuild input string with modified words with spaces
event.value = aInput.join(' ');
var aInput2 = event.value.split("-"); // make an array split at space
var sCharacter2 = '';
var sWord2='';
// for each element of word array, capitalize the first letter
for(i = 0; i <aInput2.length; i++) {
aInput2[i] = aInput2[i].substr(0, 1).toUpperCase() + aInput2[i].substr(1);
} // end loop for input string
// rebuild input string with modified words with spaces
event.value = aInput2.join('-');