Function not fully completing every other time called

The function shown below is trying to take data from a text input and refresh the data displayed. I am trying to get it to do so when the enter key is pressed. But it only refreshes on the second time enter is pressed. The “Enter pressed” is traced twice, but the “Enter Frame” is only shown after the second “Enter pressed” trace. Any ideas as to why it doesn’t do so every time?

trace("Enter Frame")
function locRefresh(evt:KeyboardEvent) {
    if(evt.keyCode == Keyboard.ENTER) {
        zipCode = locInput.text;
        trace("Enter Pressed");
        gotoAndPlay(2)
    }
}