I'd say: debug it :-) insert some print() statements in the code to see if it gets triggered. Or just print out the variable "code", e.g.
(you would need to run the viewer from a terminal to see that output, however)
But before that: Did you comment out the line in the configuration file that sets K3 specific codes? It's on top of the config file.