Harambee Stars may find its way in the last 16 if it qualifies as one of the best four third-placed teams, depending on the results in the final games in Group E and F.
Senegal’s Sadio Mane shook the net twice to steer his team ahead of Kenya and secure a place for the team in the last 16.
Kenya’s keeper Patrick Matasi impressed when he saved Sadio’s penalty kick in the first half.
Senegal came second with six points, Kenya third with three points as Tanzania trailed the group pointless.
Senegal’s first half was poor but in the second half, they changed their game to put to shame Kenya’s Sebastien Mine who had said they lacked mental strength.
Algeria maintained its position at the top of Group C after it beat Senegal and beat Tanzania 3-0 to collect nine points.
Mane then converted a second spot-kick after Philemon Otieno was sent off for a dangerous tackle on Sarr late on.
Senegal will play Uganda on July 5.