Train
One way to get to Hornbæk is by taking the very scenic Øresunds train from either Copenhagen Central, Nørreport- or Østerport station to Elsinore, and then take the small regional train, that depart every half hour on weekdays, along the north coast to Hornbæk St. A trip that takes about 1.5 hours in total. You could also take the car to Hornbæk, a trip that takes approximately an hour.
Train
You can also take the Copenhagen S-Train and switch at Hillerød to the regional train that goes to Hornbæk. This also takes about 1.5 hours, but there are more stations within Copenhagen at which you can board the train, depending on where you might be staying.