I would like to catch a KeyBoardInterrupt by a User (CTRL + C) in Java in order to aboard a password input from a user in Java in the Console. In Python there exists the easy possibility to just catch a KeyBoardInterrupt (as an exception). As I know there is nothing equivalent in Java but I would really dislike to use a shutdownhook (which were the suggestions I read in other threads) as this would destroy the Main-Thread anyway and make the whole project 10,000 times more difficult.
This means I would rather find a solution like an Exception I can catch or at least a Code-Workaround around the Use of the Java-Shutdownhook...
I would really love a solution which is still system-independent but the most I need it on Linux.
Thanks in advance