Why have the authour used the question form in this sentence? Why not statement form?
My question is based on below.
Context: It’s a conversation between Jane and Alex. Jane says:
“Only when I heard your voice did I know you were here, Alex. I could not believe my eyes."
I came across the above sentence while reading a book. Generally, we don’t use question form in the middle of a sentence. Instead, we always use statement form. But in this sentence, it is the other way round (“did I know”). Is it wrong or another literary way of expressing the same idea? If so, could you please show me more simple examples on this application?
Thanks in advance!