]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/events/KeyListener.java
Remove invalid SHA-256-Digests
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / src / org / eclipse / swt / events / KeyListener.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2016 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *     Lars Vogel <Lars.Vogel@vogella.com> - Bug 507185
14  *******************************************************************************/
15 package org.eclipse.swt.events;
16
17
18 import java.util.function.*;
19
20 import org.eclipse.swt.internal.*;
21
22 /**
23  * Classes which implement this interface provide methods
24  * that deal with the events that are generated as keys
25  * are pressed on the system keyboard.
26  * <p>
27  * After creating an instance of a class that implements
28  * this interface it can be added to a control using the
29  * <code>addKeyListener</code> method and removed using
30  * the <code>removeKeyListener</code> method. When a
31  * key is pressed or released, the appropriate method will
32  * be invoked.
33  * </p>
34  *
35  * @see KeyAdapter
36  * @see KeyEvent
37  */
38 public interface KeyListener extends SWTEventListener {
39
40 /**
41  * Sent when a key is pressed on the system keyboard.
42  *
43  * @param e an event containing information about the key press
44  */
45 void keyPressed(KeyEvent e);
46
47 /**
48  * Sent when a key is released on the system keyboard.
49  *
50  * @param e an event containing information about the key release
51  */
52 void keyReleased(KeyEvent e);
53
54 /**
55  * Static helper method to create a <code>KeyListener</code> for the
56  * {@link #keyPressed(KeyEvent e)}) method with a lambda expression.
57  *
58  * @param c the consumer of the event
59  * @return KeyListener
60  * @since 3.106
61  */
62 static KeyListener keyPressedAdapter(Consumer<KeyEvent> c) {
63         return new KeyAdapter() {
64                 @Override
65                 public void keyPressed(KeyEvent e) {
66                         c.accept(e);
67                 }
68         };
69 }
70
71 /**
72  * Static helper method to create a <code>KeyListener</code> for the
73  * {@link #keyReleased(KeyEvent e)}) method with a lambda expression.
74  *
75  * @param c the consumer of the event
76  * @return KeyListener
77  * @since 3.106
78 */
79 static KeyListener keyReleasedAdapter(Consumer<KeyEvent> c) {
80         return new KeyAdapter() {
81                 @Override
82                 public void keyReleased(KeyEvent e) {
83                         c.accept(e);
84                 }
85         };
86 }
87
88 }