key-bindings

Certain key combinations don't work in a Java game

白昼怎懂夜的黑 提交于 2019-12-13 05:31:14
问题 EDIT: Added code. In a 2D Java game, I have two tanks on the screen. Their controls: Tank 1 Move forward: UP arrow key Adjust angle of movement (and rotate sprite): LEFT arrow and RIGHT arrow. Shoot missile: ENTER key. Tank 2 Move forward: W key Adjust angle of movement (and rotate sprite): A key and D key. Shoot missile: G key. The program uses Key Bindings to do this. I have a wierd bug: Pressing W, D, and G at the same time - works. (aka: rotating the sprite to the right and adjusting the

(Tkinter) Command executed automatically when binding, binding not acting as expected

人盡茶涼 提交于 2019-12-13 05:07:26
问题 I am trying to bind a key to a command conditionally. But when I bind, the command gets automatically executed (when I toggle both commands). Why does that happen? And how can I only bind a command without executing it? Also after binding both commands, only the first one (function p) is being executed. Why is that? My code is as follows: from tkinter import * top = Tk() editor = Text(top) editor.pack() def br(event=None): try: editor.insert(INSERT, "<br />") except: pass def ins_br(): br()

Java animation, with key listener

霸气de小男生 提交于 2019-12-13 04:44:45
问题 I tried to make it so that,if I pressed the right/left key, the sprite/Mario would face right/left. If I pressed the right key, he would face right. But for some reason, When I pressed the left key, he won't face left. Source Code: First ,Second Images 回答1: "To fire keyboard events, a component must have the keyboard focus."—How to Write a Key Listener 回答2: Don't use a KeyListener. Instead use Key Bindings which are more flexible and are used by all Swing components. 来源: https://stackoverflow

Action from KeyBinding don't execute on a JTable cell

早过忘川 提交于 2019-12-13 04:23:44
问题 im having a problem that is cause i CAN edit the cell when not having focus but when i press the bind key in the cell ("Enter"), action is not performed. But when is has focus, action is performed correctly. I only want to add the keybinding for that specific cell (row,col) , so i added to the textfield in the render. May be im doing something bad. 回答1: As you tab from cell to cell focus in still on the table. The editor is only invoked when you double click with the mouse or use F2 with the

How to bind ESC key to close a `gwindow()` in gWidgets?

﹥>﹥吖頭↗ 提交于 2019-12-13 02:56:16
问题 Consider: require(gWidgets2) w <- gwindow("notebook example", visible=T) nb <- gnotebook(container=w) gbutton("Page one", label="tab 1", container=nb) ## note label argument gbutton("Page two", label="tab 2", container=nb) How can I bind a given key (say, ESC ) to close the gwindow() in gWidgets, that is to execute dispose(w) ? In other words, how do you assign keybindings in gWidgets? 回答1: With RGtk2 (and possibly others) the addHandlerKeystroke method can be used to catch keystrokes. You

How to assign newline functionality in Ubuntu Jaunty to Enter directly?

北城余情 提交于 2019-12-13 02:33:16
问题 In Ubuntu Jaunty the Enter key is apparently translated to Ctrl-m symbol. I'd like to free Ctrl-m symbol from newline functionality to make it available for other commands. In this case I guess I should translate Enter to newline directly. How do I do that? I'm talking about key reassignment in gnome-terminal. 回答1: (global-set-key (kbd "<return>") 'newline) 来源: https://stackoverflow.com/questions/2299142/how-to-assign-newline-functionality-in-ubuntu-jaunty-to-enter-directly

autohotkey Media_Play_Pause not mapped to Pause but mapped to ^Space

拜拜、爱过 提交于 2019-12-13 01:08:32
问题 Since Spotify changed to their latest version the old Play/Pause through ControlSend, ahk_parent, {space}, ahk_class SpotifyMainWindow stopped working. It seems Spotify can now capture the Media keys and as suggested by other members the following works: ^Space::Media_Play_Pause HOWEVER mapping to the Pause key doesn't work. Pause::Media_Play_Pause Any idea why??? FYI here is the scan of the keys: Working (^Space): VK SC Type Up/Dn Elapsed Key Window ------------------------------------------

how to find where a key binding is defined in emacs?

纵饮孤独 提交于 2019-12-13 00:29:01
问题 Somehow shift + m is got bound to Meta key in emacs. Now I cant type any words that start with M like Mock . I want to find why it is happening or which package is causing this. There is one question regarding this issue but doesn't solve this problem. I tried C h k m which showed m runs command self-insert-command But when when i try C h k M it is activating Meta key and is waiting for another key to input. The same is happening with C h c M . Is there any way to find out what is causing

key-bindings and holding down keys

喜你入骨 提交于 2019-12-12 18:12:42
问题 I have created a key binding for a JTextArea Component. When invoked, it creates a new instance of itself and sets focus to it. If you hold down the enter (which invokes key binding) my program will start spitting out bunch of JTextArea instances. Is there a way to force the user to press enter againg to create a new instance? Do I have I switch to KeyListeners or is there a way with key bindings? 回答1: the way to do it with keybindings is to have two actions: an action creating the component

Listening for key strokes in a nested panel

落爺英雄遲暮 提交于 2019-12-12 16:14:40
问题 In the Java file below, I create a frame containing a panel, which then nests a second panel. I'm trying to listen for key strokes in the nested panel. My approach is to use an input map and an action map. I've found if I only have an input map for the nested panel, things work as expected. However, if the parent panel also has an input map, key stroke events are not passed to the nested panel. You can observe this behavior by commenting and uncommenting the first call to getInputMap().put.