Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support keyboard shortcuts #15

Open
Demfier opened this issue Nov 23, 2017 · 12 comments
Open

Support keyboard shortcuts #15

Demfier opened this issue Nov 23, 2017 · 12 comments

Comments

@Demfier
Copy link
Collaborator

Demfier commented Nov 23, 2017

It would be nice to have support for keyboard shortcuts such as Tab to give indentation, shortcuts to move a line of code up/down etc.

@Demfier Demfier changed the title Ssupport keyboard shortcuts Support keyboard shortcuts Nov 23, 2017
@142ayushkumar
Copy link
Collaborator

Can you assign me this issue?

@Demfier
Copy link
Collaborator Author

Demfier commented Dec 13, 2017

@142ayushkumar - I have assigned this issue to you.
Make sure when you make the PR you enumerate a list of keyboard shortcuts that you've added.

@Demfier
Copy link
Collaborator Author

Demfier commented Dec 13, 2017

Update: @142ayushkumar working demo isn't required. #33 will take care if it.

@142ayushkumar
Copy link
Collaborator

I have a separate .js and .html file and tab works in text area (just to check that my js file is working or not)
but they don't work in this project, any idea where i did mistake?

@Demfier
Copy link
Collaborator Author

Demfier commented Dec 14, 2017

@142ayushkumar : It would greatly help if you could provide us with the code or something. And by the way you'll have to run python manage.py collectstatic command if you've introduced new static files (html, js, css, images etc) to make sure they are loaded in the app. This is just a hinch though. I would be able to tell you better if you "show" me what you are doing 😄

@142ayushkumar
Copy link
Collaborator

Added this in index.html

{% load staticfiles %}
<script src="{% static "js/my.js" %}"></script>

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="static/js/my.js"></script>
</head> 

and in my.js


$(document).delegate('#textbox', 'keydown', function(e) {
  var keyCode = e.keyCode || e.which;

  if (keyCode == 9) {
    e.preventDefault();
    var start = this.selectionStart;
    var end = this.selectionEnd;

    // set textarea value to: text before caret + tab + text after caret
    $(this).val($(this).val().substring(0, start)
                + "\t"
                + $(this).val().substring(end));

    // put caret at right position again
    this.selectionStart =
    this.selectionEnd = start + 1;
  }
});

and yes, i did this python manage.py collectstatic too

@Demfier
Copy link
Collaborator Author

Demfier commented Dec 14, 2017

I think the issue stands here with the way you are referring to them. Try using /static/js/my.js instead the way you are using now. Also, as a thumb rule, you should always check your browser's console to get a direction to start you debugging. Let me know if that helps.

@142ayushkumar
Copy link
Collaborator

Sorry for my bad, i used /static/js/my.js , was just tweaking and then i copied the code, i used
/static/js/my.js ,it doesn't work

@Demfier
Copy link
Collaborator Author

Demfier commented Dec 14, 2017 via email

@Demfier
Copy link
Collaborator Author

Demfier commented Dec 14, 2017

Also, I think it's better if you make a PR.

@142ayushkumar
Copy link
Collaborator

[14/Dec/2017 12:15:29] "GET / HTTP/1.1" 200 13504
[14/Dec/2017 12:15:29] "GET /static/js/my.js HTTP/1.1" 304 0
[14/Dec/2017 12:15:29] "GET /static/css/mystyle.css HTTP/1.1" 304 0
[14/Dec/2017 12:15:29] "GET /static/js/terminal_fill.js HTTP/1.1" 304 0
[14/Dec/2017 12:15:29] "GET /static/js/my.js HTTP/1.1" 304 0
[14/Dec/2017 12:15:30] "GET /static/img/logo.ico HTTP/1.1" 304 0

@Demfier
Copy link
Collaborator Author

Demfier commented Dec 14, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants