public static KeyboardState Join(ISpread <int> keys, bool capsLock, int time) { switch (keys.SliceCount) { case 0: return(KeyboardState.Empty); case 1: var key = keys[0]; if (key == 0) { return(new KeyboardState(Enumerable.Empty <Keys>(), capsLock, time)); } else { return(new KeyboardState(keys.Cast <Keys>(), capsLock, time)); } default: return(new KeyboardState(keys.Cast <Keys>(), capsLock, time)); } }