Converted to class and using keys in array

I converted the code to a class-like format, so it can be reused on the
same page, and I changed the ascii array to use the letters in the text
as keys instead of using indexOf() to improve performance.