handleKeyPress: Fix shadowing of global 'index' variable