Ideas come at any moment -- except when you demand them. Most ideas come while I'm physically active, at the gym, with friends, gardening, so I always carry pen and paper. My first draft is always written in longhand. But once the first dozen chapters, more like short stories, are written, then momentum builds until I can't leave the project until it's done.
It's usually a big kind of vent of frustration or anger or sadness that puts me in the right frame of mind to write. It's such a cliche to say that artists write when they're down, but it's true for me. It's a relief to get out what's eating away at my heart or my soul or my head.