Neither side could be completely satisfied with the result.
Costa Rica has just one win this season, and was looking for momentum in its final tune-up for the World Cup.
Ireland, which failed to qualify for the World Cup, was hoping Keane's return would boost a sagging attack. The Irish mustered two goals in four games without Keane, who was away playing for his club team, the Los Angeles Galaxy.
This game turned during a two-minute stretch in the second half.
Ireland was leading by 1-0 when its goalie, David Forde, tripped Marco Urena in the penalty area. Celso Borges converted the penalty to level the score at 1-1. A minute later, Ireland's Stephen Quinn was taken down in the box to set up Keane's ill-fated attempt.
The first half belonged to Ireland's Kevin Doyle, or more specifically, his head.
Doyle's long header from the top of the box to give Ireland a 1-0 lead in the 18th minute. Late in the half, Costa Rica's Giancarlo Gonzalez earned a red card by delivering an elbow to Doyle's head. Doyle walked off the pitch holding a hand to his face as blood streamed down.
But down a man following the Gonzalez ejection, Costa Rica played its best soccer of the night and carried play in the second half. Aside from Keane's penalty, the Irish provided little threat.
"They played better with 10 than we did with 11," Irish manager Martin O'Neill said.