key-bindings

Java keyboard input - game development

∥☆過路亽.° 提交于 2019-11-28 06:42:17
问题 I have a specific "problem" with a game I'm creating for class. The game is an implementation of "Break it". To move the platform at the bottom I just used a key listener. The problem is that after the first key press there is a short "lag" or "stutter" before the platform starts moving. How could I prevent this to get a smooth response? Is there another way than KeyListener? KeyBindings? Here is the key listener implementation private class KeyControl implements KeyListener { private int dx

How to bind Ctrl+/ in python tkinter?

北战南征 提交于 2019-11-28 06:32:47
<Control-Shift-Key-0> <Control-Key-plus> works but <Control-Key-/> doesn't. I am unable to bind ctrl + / in python. Is there any documentation of all the possible keys? Use <Control-slash> : def quit(event): print "you pressed control-forwardslash" root.quit() root = tk.Tk() root.bind('<Control-slash>', quit) # forward-slash # root.bind('<Control-backslash>', quit) # backslash root.mainloop() I don't have a link to a complete list of these event names. Here is a partial list I've collected: | event | name | | Ctrl-c | Control-c | | Ctrl-/ | Control-slash | | Ctrl-\ | Control-backslash | | Ctrl

How do you make key binding for a JFrame no matter what JComponent is in focus?

十年热恋 提交于 2019-11-28 03:46:54
问题 How do we make key bindings for a JFrame regardless of what's in focus in the frame? I already looked at this question: How do you make key bindings for a java.awt.Frame? I tried setting the input map for the root pane of the JFrame, but it doesn't work when the focus is on a JTextArea even though editable is false. What's the easiest way to make key bindings work across an entire JFrame? 回答1: I tried setting the input map for the root pane of the JFrame, but it doesn't work when the focus is

Calculator application including keyboard input in java swing

走远了吗. 提交于 2019-11-28 02:03:46
I have a calculator application in java swing, which is working properly with mouse click input. Now I want it to read input using keyboard button stroke. I had heard about the glass pane in java tutorial, but i need to know any other simple method to meet the requirement. KeyPadPanel is an example that uses Action and Key Bindings for numeric entry. 来源: https://stackoverflow.com/questions/10099686/calculator-application-including-keyboard-input-in-java-swing

Java Keybindings [closed]

怎甘沉沦 提交于 2019-11-28 01:45:12
I need to bind all the arrow keys to perform the same function but each time get which key was pressed. Currently I only have when the right arrow key is pressed via the following DoneImg.getInputMap(JLabel.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "UpArrow"); Action MvRight = new AbstractAction() { public void actionPerformed(ActionEvent e) { //Do whatever here } }; DoneImg.getActionMap().put("RightArrow", MvRight); But I need something like DoneImg.getInputMap(JLabel.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), "RightArrow"); DoneImg

Window.InputBindings with a bound collection

对着背影说爱祢 提交于 2019-11-28 01:23:39
I can't find anything that looks like this online. I am looking for a way to create a collection of Keybindings in the code (with a Keybinding ViewModel), and then bind the collection to the view, instead of listing out every binding manually in Xaml. I would expect it to look something like this <Window.InputBindings ItemsSource="{Binding Path=KeybindingList}" /> and then in the code, have a List. Is such an approach possible? Where would I start? You can create an attached property , listen to its changes and modify the InputBindings collection of the associated window. An example: //

How do I bind a key to “the function represented by the following key sequence”?

Deadly 提交于 2019-11-28 00:25:40
问题 I'm just starting to learn emacs (woohoo!) and I've been mucking around in my .emacs quite happily. Unfortunately, I don't know Lisp yet, so I'm having issues with the basics. I've already remapped a few keys until I fix my muscle memory: (global-set-key (kbd "<f9>") 'recompile) That's fine. But how can I tell a key to 'simulate pressing several keys'? For instance, I don't know, make <f1> do the same as C-u 2 C-x } (widen buffer by two chars). One way is to look up that C-x } calls shrink

Comparing functionality between KeyListeners and Key Bindings

微笑、不失礼 提交于 2019-11-28 00:03:51
This question arose when an anonymous user downvoted an answer of mine involving KeyListeners and suggested the use of Key Bindings instead. This anonymous user informed me that the KeyListener interface was an old AWT solution and should not be used. However, I don't know if I should trust that information completely. I have researched both on various websites, oracle included, and found nothing regarding the functionality of KeyListeners or Key Bindings. I am aware of the fact that the two perform similar tasks, but am unsure of exactly what goes on "behind the scenes", so to speak. I'm kind

In emacs23 how to bound C-<return> to C-<return> instead of C-J

*爱你&永不变心* 提交于 2019-11-27 23:10:18
问题 I am trying to use org-mode and whenever I press Crtl+return emacs does C-J instead. I know this because when I use c-h k and then press crtl+return, emacs shows: "It is bound to C-j." Is there anyway I can make it register ctrl+return so I can insert headings? I am using emacs23 through the terminal on ubuntu 12.04 x64. When I do this on my windows machine it does insert a new heading. 回答1: Possibly. As @phils says, C-Enter is usually not a valid sequence for the vast majority of terminal

Detect if a key is bound to something in vim

随声附和 提交于 2019-11-27 19:46:45
问题 I'd like to know if there is a way to figure out if a key does something in vim. I know that I can use :map to see user-defined mappings, but is there something for the built-in stuff? For example, I always had CTRL - W bound to close tab, because I thought that it was unused. After half a year, I found out that there are some sequences that use it, like CTRL - W CTRL - S to split the window, and it was a nightmare to retrain myself. 回答1: If you check out the suggested answer by Randy Morris