diff --git a/ym-barcode/src/main/java/com/cnbm/barcode/listener/GlobalKeyListenerExample.java b/ym-barcode/src/main/java/com/cnbm/barcode/listener/GlobalKeyListenerExample.java index ddff3ec..1bc1d10 100644 --- a/ym-barcode/src/main/java/com/cnbm/barcode/listener/GlobalKeyListenerExample.java +++ b/ym-barcode/src/main/java/com/cnbm/barcode/listener/GlobalKeyListenerExample.java @@ -40,8 +40,9 @@ public class GlobalKeyListenerExample implements NativeKeyListener { } catch (InterruptedException ex) { ex.printStackTrace(); } + log.info("queue的数据是:"+queue.toString()); int[] hotKeyArray1 = {NativeKeyEvent.VC_X, NativeKeyEvent.VC_Y,NativeKeyEvent.VC_Z}; - if (queue.size() == 5 && e.getKeyCode() == NativeKeyEvent.VC_ENTER && judgeCombinationKey(hotKeyArray1)){ + if (5 <= queue.size() && queue.size()<= 6 && e.getKeyCode() == NativeKeyEvent.VC_ENTER && judgeCombinationKey(hotKeyArray1)){ String result = ""; List collect = queue.stream().map(n -> { return NativeKeyEvent.getKeyText(n); @@ -50,7 +51,11 @@ public class GlobalKeyListenerExample implements NativeKeyListener { for (String s : collect) { result = result + s; } - log.info("符合标准的扫码是:"+ result); + if (queue.size() == 5) { + log.info("符合标准的扫码是:"+ result.replace("Enter","")); + }else { + log.info("符合标准的扫码是:"+ result.substring(1).replace("Enter","")); + } queue.clear(); } if (queue.size() == 6){