Added key interaction code