Mirror key handler functionality in original JS version