To wake up her game, which had dozed off under the midafternoon sun late in the second set of her third-round match against Naomi Osaka, Keys heard the alarm inside her head and the cacophonous support of a crowd swelling in numbers and harboring faint hope that she could actually survive a 5-1 deficit in the third set.

“Step up or lose,” she said later, with the 20/20 hindsight of knowing she had survived the challenge of the 18-year-old Osaka, 7-5, 4-6, 7-6 (3).

After winning the first set and holding a 40-0 lead at 4-4 in the second, Keys began spraying groundstrokes in all directions and lost seven of the next eight games. It is the mystery of her power game, still lacking in subtlety and vulnerable to spasms of overcooked groundstrokes on too many game-turning points.

“Everybody knows she has a big game,” said Keys’s coach, Thomas Hogstedt. “But sometimes she lacks the experience on the big points.”

Keys has been considered a future star from the time she played the United States Open five years ago as a 16-year-old, arriving with the charming story of her initial attraction to tennis — a white dress worn by Venus Williams at Wimbledon.

In June, she barged into the top 10, the first American to do so since Serena Williams in 1999. And for all of the surprising American success during the tournament’s first week — continuing Friday with Jack Sock’s straight-set defeat of Marin Cilic, the 2014 champion and No. 7 seed — Keys figured to be the country’s best hope outside of Williams for a final weekend appearance.

Carrying the No. 8 seed, she proceeded to barely win a first-round match against a fellow American, Alison Riske.

Osaka, Keys’s opponent Friday, appears to be a rising star in her own right. She is the daughter of a Japanese mother and a Haitian father. Born in Japan — the country she represents in tennis — she has spent most of her life in the United States.

Osaka is generously listed at 5 feet 11 inches, or one inch taller than the power-hitting Keys. But it was her athleticism, power and precision that had Hogstedt daring to compare Osaka to a certain American who is bidding to become the leader in Grand Slam tournament victories in tennis’s Open era, in pursuit of her 23rd.

“When you see her game, she reminds me a little bit of Serena, the style she plays,” Hogstedt said. “She’s very, very strong. She’s for sure going to be up there in the top 20.”

It was Williams who not long ago tagged Keys as her potential successor at the top of the sport. “Very nice of her to say,” Keys said. “More than anything, it makes me want to go out to work and get better.”

But forecasts for greatness are always easier than the arduous climb through the rankings, week after monotonous, pressure-filled week. Last year, Keys was a semifinalist at the Australian Open and a quarterfinalist at Wimbledon. But when people see the winners that explode off her racket, and her high-octane serve, they often wonder why she has not already done more.

At 21, she said her goal this year was to continue reaching the second week of the Grand Slam tournaments, which she accomplished Friday — giving herself a chance for a career-defining breakthrough.

Hogstedt, who briefly coached Eugenie Bouchard and in April became the latest in a series of coaches for Keys, said he thought it might all have been happening at Wimbledon until Keys lost a round-of-16 match to Simona Halep in which Keys had led by a set and a break.

“I thought she had a chance to win the tournament, but she let that one go,” he said. “Sometimes these things stay with you, and that’s why I think this win is the best thing that can happen for her. It’s unbelievable to come back from 5-1. She didn’t give in.”

Keys had practiced once for an hour with Osaka, who is ranked No. 81 in the world. After a childhood in New York, Osaka now lives in Fort Lauderdale, Fla.

“She’s got a great serve, a great forehand, very aggressive,” Keys said. “I like how she plays.”

As for her own game, Keys seemed to shrug and ask herself what she had to lose at 5-1 in the third set. Without warning, her groundstrokes began landing deep in the court as opposed to a foot or two out. The fans shouted encouragement when she held serve for 5-2; they roared her name — “Maddy! Maddy!” — when she broke for 5-3.

Osaka’s collapse was not total. After losing five straight games, she held to force a decisive tiebreaker. The key points, with Keys leading by 3-2, were consecutive forehand winners off second serves.

“I have something to pat myself on the back for,” Keys said.

Along with a fourth-round match against Caroline Wozniacki. The second week beckons.

A version of this article appears in print on , on Page D4 of the New York edition with the headline: Slumbering Into the Third Set, Then Arising With a Rally to Build On. Order Reprints | Today’s Paper | Subscribe