Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Refactors key press code

AuthorDaveJarvis <email>
Date2023-01-26 18:44:00 GMT-0800
Commit0f89f2c3cc945227431362383d4278e1d7f0c45a
Parente7089a7
Delta13 lines added, 12 lines removed, 1-line increase
src/main/java/com/keenwrite/MainApp.java
/**
+ * Creates an instance of {@link KeyEvent} that represents a key released
+ * event without any modifier keys held.
+ *
+ * @param code The key code representing a key to simulate releasing.
+ * @return An instance of {@link KeyEvent}.
+ */
+ public static Event keyDown( final KeyCode code ) {
+ return keyDown( code, false );
+ }
+
+ /**
* Creates an instance of {@link KeyEvent} that represents releasing a key.
*
* @param code The key to simulate being released up.
* @param shift Whether shift key modifier shall modify the key code.
* @return An instance of {@link KeyEvent} that may be used to simulate
* a key being released.
*/
+ @SuppressWarnings( "unused" )
public static Event keyUp( final KeyCode code, final boolean shift ) {
return keyEvent( KEY_RELEASED, code, shift );
- }
-
- /**
- * Creates an instance of {@link KeyEvent} that represents a key released
- * event without any modifier keys held.
- *
- * @param code The key code representing a key to simulate releasing.
- * @return An instance of {@link KeyEvent}.
- */
- public static Event keyUp( final KeyCode code ) {
- return keyUp( code, false );
}
stage.focusedProperty().addListener( ( c, lost, found ) -> {
if( found ) {
- mMainScene.getMenuBar().fireEvent( keyDown( ESCAPE, false ) );
+ mMainScene.getMenuBar().fireEvent( keyDown( ESCAPE ) );
}
} );