forget to check for InputRange of byKey and added ElementKeyType(R)