That code won't run. Actually, it won't compile because the negation operator cannot be applied to any type other than an object of type Boolean. In your case, you're applying it to an integer.
Anyhow, it's a bit overkill to use p-invoke when the Console class provides all the methods (ReadKey() in this case) that do the exact same thing.