Remember that Peter denied Jesus too. Three times, to be exact. Judas handed him over, but Peter did nothing to stand up for his Lord when confronted. And yet one went and hung himself, and one was given the keys to the kingdom.
How can this be?
Just one word separates the two. Repentance.
Judas was ravaged with guilt. He turned in on himself. Failed to ask for forgiveness. Now we use his name to refer to traitors.
Peter felt guilt, too. But Peter ran to Jesus upon hearing He was missing from the tomb. Later, Jesus asked Peter if he loved Him. Three times, no less. The same amount of times Peter denied Him. To each question, Peter answered, "You know that I love you."
Repent. Show you love God. Follow His commands.
There is a fine line between Peter and Judas. Jesus and His infinite Mercy is on one side. On the other side is eternal damnation.