Same instance getting fired
opened this issue · comments
I have p+0
and m+0
assigned.
I saw that when I m+0
is pressed, it shows p+0
as keyname
.
Here is the code.
onKeyDown(keyName, e, handle) {
const key = handle.key;
console.log(handle);
switch (key) {
case 'p+0':
case 'p+1':
case 'p+2':
case 'p+3':
case 'p+4':
case 'p+5':
case 'p+6':
case 'p+7':
case 'p+8':
case 'p+9':
try {
const currentPosition = this.giveWarningIfNoPositionSelected();
let openingSize = key.replace(/(p\+)/i, '');
if (openingSize === '0') {
openingSize = parseFloat(currentPosition.quantity);
} else {
const percentage = parseFloat(openingSize) * 10;
openingSize = (parseFloat(currentPosition.quantity) * percentage) / 100;
}
const openingPositionSide = /-/.test(openingSize) ? 'sell' : 'buy';
const msg = 'Placing ' + openingPositionSide + ' market order for ' + currentPosition.symbol + ' on ' +
strCapitalize(currentPosition.exchange_name) + '' +
' with qty ' + openingSize;
if (window.confirm(msg)) {
const data = {
exchange_name: currentPosition.exchange_name.toLowerCase(),
symbol: currentPosition.ccxt_symbol,
type: 'market',
side: openingPositionSide,
quantity: parseFloat(openingSize),
time_in_force: 'GTC'
};
this.placeOrder(data);
}
} catch (e) {
}
break;
case 'm+0':
case 'm+1':
case 'm+2':
case 'm+3':
case 'm+4':
case 'm+5':
case 'm+6':
case 'm+7':
case 'm+8':
case 'm+9':
console.log('here');
break;
}
So, when I basically press m+9
, the code in p+n
is getting executed and it's showing me the confirm
which should not happen.
A quick reply would be appreciated.
Thank you in advance.
@koushik72 Must be combined with modifier keys
const _modifier = { // 修饰键
'⇧': 16,
shift: 16,
'⌥': 18,
alt: 18,
option: 18,
'⌃': 17,
ctrl: 17,
control: 17,
'⌘': isff ? 224 : 91,
cmd: isff ? 224 : 91,
command: isff ? 224 : 91,
};
Hi, thank you for the reply.
I have these two now.
shift+c+1
and shift+m+0
. When I press shift+m+0
, the code for shift+c+1
gets fired.
Why is that?
ctrl+shift+1
and ctrl+shift+2
or
ctrl+alt+1
and ctrl+alt+2
@koushik72 Shortcut definition
modifier key
+key
modifier key
+modifier key
+key
modifier key
+modifier key
+modifier key
+key
I can't see those Chinese texts. I can only understand those shortcut icon.
I have one question. Is it possible to execute different code when shift+c and shift+p are pressed?
Thank you.
I have one question. Is it possible to execute different code when shift+c and shift+p are pressed?
of course can
Of course you can execute different code
But I am having trouble with that part.
I have these keys
const keynames = 'up,w,s, down, shift+c+0, shift+d+0';
Now for onKeyDown
event when I check the name, it shows the keyname as
shift+c+0
even when I pressed shift+d+0
.
Why is that?
bad
Does not support modifier key
+ key
+ key
shift+c+0
shift
=> modifier keyc
=> key0
=> key
good
Support modifier key
+ modifier key
+ key
shift+ alt +0
shift
=> modifier keyalt
=> modifier key0
=> key
Hi, thank you for the clarification, That did help me. Do you know any library that supports it?
I do not know. If you know, please tell me. thx!