"Hanky Panky" was recorded within the three weeks time taken for the whole project. Personnel working on the song included Leonard on keyboards, Jeff Porcaro on drums, Guy Pratt on bass and Donna De Lory, Niki Haris and N'Dea Davenport on background vocals. Lyrically, the song deals with sadomasochistic themes and is centred around a girl who celebrates the pleasures of a "good spanking". It is performed in an almost comical style and stemmed from a line in the film, where Breathless says to Tracy, "You don't know whether to hit me or kiss me". The track has a false introduction and starts slowly with piano, but changes after a few moments into a large jazz and swing song, with a changing bassline and minor to major key-shift in the chorus. According to the sheet music published by Musicnotes.com, the song is set in common time, with a tempo of 170 beats per minute. It is composed in the key of D minor, with Madonna's vocals spanning from B3 to D5. The song has a basic sequence of Dm–C–Bm–A7sus in the beginning and changes to Dm–A–B9–A7–Dm–C when the swing starts. During an interview with "Rolling Stone", Madonna explained: