added automatic toc generation to keypress events