KZcoding
KZcoding

Reputation: 1517

Ace editor: How to get position of keyboard event

Currently, I am getting events whenever any key is pressed in my ace editor, via this javascript code:

editor.keyBinding.addKeyboardHandler({
    handleKeyboard: function(data, hash, keyString, keyCode, event) {

keyString contains the actual key pressed, but how do I find the position (i.e. row and column) of where the key event took place?

Upvotes: 0

Views: 358

Answers (2)

Harsha pps
Harsha pps

Reputation: 2208

You could use

 var currentPosition = editor.selection.getCursor();

You could use the currentPosition to find the row and column position where the key event took place. (currentPosition.row and currentPosition.column)

Upvotes: 2

a user
a user

Reputation: 24104

Key event doesn't take place in any position, but in the editor as a whole.

You can use editor.getCursorPosition() to find the position of the cursor.

Upvotes: 1

Related Questions