I'm stuck.
I want the user to press enter key to proceed, but I don't know how to detect enter key press.
please help.
For further actions, you may consider blocking this person and/or reporting abuse
I'm stuck.
I want the user to press enter key to proceed, but I don't know how to detect enter key press.
please help.
For further actions, you may consider blocking this person and/or reporting abuse
Daniel Bemsen Akosu -
Kauna Hassan -
Dennis -
Waji -
Once suspended, programmerno24 will not be able to comment or publish posts until their suspension is removed.
Once unsuspended, programmerno24 will be able to comment and publish posts again.
Once unpublished, all posts by programmerno24 will become hidden and only accessible to themselves.
If programmerno24 is not suspended, they can still re-publish their posts from their dashboard.
Once unpublished, this post will become invisible to the public and only accessible to Darsh.
They can still re-publish the post if they are not suspended.
Thanks for keeping DEV Community safe. Here is what you can do to flag programmerno24:
Unflagging programmerno24 will restore default visibility to their posts.
Top comments (1)
I'm assuming you mean in a console application.... You can use a
Scanner
. ThehasNextLine
method will return true if they enter anything. You can follow that with a call tonextLine
which will remove that line from the input stream and return it to you. If you literally only want to proceed if they pressed only the enter key and nothing else then you can check if the string returned is the empty string.Note that the
hasNextLine
will never return false if Scanner reading fromSystem.in
. It will wait for input and then return true.