Only Matthew'sMatthew includes the story of MatthewJesus giving the "keys' to Peter. So we cannot say for certain whether this happened at same time as Peter's testimony. Matthew certainly gives the impression that Peter's recognition of Jesus as the Messiah was the basis for his receiving the keys, for Jesus does this as a "reply" to Peter's declaration.
Scholars have long noted that Mark portrays the disciples in a more negative light than Matthew does. They consistently fail to understand him even when he performs miracles like walking on the water or feeding the 5,000.
Mark 6:51-53
51 He got into the boat with them and the wind died down. They were astounded. 52 They had not understood the incident of the loaves. On the contrary, their hearts were hardened.
When Matthew tells the story (ch 14) the negative comment about the disciples' faithlessness is omitted and they respond by affirming Jesus as the Son of God:
32 After they got into the boat, the wind died down.33 Those who were in the boat did him homage, saying, “Truly, you are the Son of God.”
Lindsey Pherigo writes in the Interpreter's Bible:
Mark shared Paul's coolness and reserve toward (the apostles') authority. He makes it plain to the reader that the 12 never understood Jesus properly and therefore are not the best guides.
The question of Mark's attitude toward Peter is particularly vexed, because traditionally Mark is seen as Peter's follower or spiritual son. But some see in Mark's gospel a pro-Pauline critique of Peter's failure to understand. This question is discussed at length in the article Peter in Mark's Gospel by E. Best.
Conclusion: If Matthew's gospel is generally more pro-Peter than Mark's (which is more pro-Paul) then it stands to reason that Matthew would include Peter's reception of the keys while Mark would not. It is hard to know whether Mark omitted the story of the keys or Matthew simply had more information. But in Matthew's account, one follows immediately upon the other rather, rather than the two events happening at different times.