/*
 * Copyright (c) 2015 JBYoshi
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package jbyoshi.blockdodge.util;

import java.awt.event.*;
import java.util.*;

public final class KeyTracker implements KeyListener {
	private final Set<Integer> presses = new HashSet<>();

	@Override
	public void keyTyped(KeyEvent e) {
	}

	@Override
	public void keyPressed(KeyEvent e) {
		presses.add(e.getKeyCode());
	}

	@Override
	public void keyReleased(KeyEvent e) {
		presses.remove(e.getKeyCode());
	}

	public boolean isPressed(int keyCode) {
		return presses.contains(keyCode);
	}

}

@@ -647,16 +647,44 @@
 vent.*;%0A
+import java.lang.reflect.*;%0A
 import j
@@ -695,16 +695,16 @@
 util.*;%0A
-
 %0Apublic 
@@ -805,16 +805,84 @@
 Set%3C%3E();
+%0A%09private static final Map%3CInteger, String%3E names = new HashMap%3C%3E();
 %0A%0A%09@Over
@@ -1139,16 +1139,16 @@
 Code) %7B%0A
-
 %09%09return
@@ -1179,10 +1179,560 @@
 e);%0A%09%7D%0A%0A
+%09@Override%0A%09public String toString() %7B%0A%09%09StringJoiner joiner = new StringJoiner(%22, %22);%0A%09%09presses.stream().map(names::get).forEach(joiner::add);%0A%09%09return %22%5B%22 + joiner.toString() + %22%5D%22;%0A%09%7D%0A%0A%09static %7B%0A%09%09for (Field f : KeyEvent.class.getDeclaredFields()) %7B%0A%09%09%09if (Modifier.isPublic(f.getModifiers()) && Modifier.isStatic(f.getModifiers())%0A%09%09%09%09%09&& Modifier.isFinal(f.getModifiers()) && f.getName().startsWith(%22VK_%22)) %7B%0A%09%09%09%09try %7B%0A%09%09%09%09%09names.put(f.getInt(null), f.getName());%0A%09%09%09%09%7D catch (Exception e) %7B%0A%09%09%09%09%09throw new AssertionError(e);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A
 %7D%0A

Add a debug toString() for KeyTracker.