Foakes enjoyed a dream start to his Test career, making a century on debut in Galle to set up a series whitewash over Sri Lanka in late 2018.
But he has been in and out of the side since, losing his place first to Jonny Bairstow, then Jos Buttler. He came into this Test, his 16th, on the back of three low scores and with a Test average of 27.
Joining his captain Ben Stokes with England five down and four behind South Africa’s first-innings 151, he played an excellent hand to finish 113 not out, his second ton and highest Test score.
“It was tough out there to be honest,” said Foakes. “There’s just a sense of relief and I’m overjoyed really. Since my first game I've found hundreds aren't easy to come by in Test cricket so this one for me is very, very special.
“Obviously since since my debut a lot's gone on. That time and hard, difficult phases and injuries. And obviously a lot of time on the sidelines, I think, really makes you appreciate and value getting the opportunity and then getting another one today was amazing.
“To be honest in my first 10 games, I was kind of looking and thinking jeez how hard is Test cricket, the West Indies tour - the wickets out there - and then I came in for those three in India and it was obviously crazy to bat on and I guess this is a different role as well.
“It's a different role, at Surrey I bat five and just play. When you get on quite challenging wickets batting at seven obviously there's a good chance you lose wickets quickly and you have to play a different way. I think for me it's learning how to do that as well as I can. Just because it's not my natural game. Finding a way to be able to, quite early on in my innings, put pressure back on the bowler rather than just batting.”
Foakes admitted he would take confidence from the innings in what is an unusual role.
“It definitely gives you confidence,” he said. "Getting a hundred obviously does that. When I bat at five hundreds are definitely something I think about, but at seven I think more about just trying to contribute because obviously you're not going to get as many opportunities to get a hundred. If I can get 40 with the tail and dominate that partnership, that's my job.
“Getting a big partnership here and getting a century definitely gives me some confidence going forward.”
Foakes was ruled out of a Test earlier this summer with Covid, another frustration.
“Getting the opportunity of being number one [keeper] and then pretty soon after getting something like that is very frustrating,” he said. “I’ve had a bit of stuff going on since I first played but I'm used to little setbacks like that.”